首先感谢Kamil Lach的暗示,我设法做到了
这是我的代码,也许是某人为此使用了
在我的控制器中创建了一个函数并将模型加载到其中
function sort_items()
{
$this->load->model("admin/pages_model");
$this->pages_model->sort_insert();
}
模型
function sort_insert()
{
foreach($this->input->post("sort") as $p => $id)
{
$this->db->query(" UPDATE c_pages SET sort = ".$p." WHERE pid = ".$id." ");
}
}
$ p vaiable是空头头寸,id是菜单ID
和jquery
$( "#sortable" ).sortable({
placeholder: "ui-state-highlight",
opacity: 0.6,
update: function(event, ui) {
var info = $(this).sortable("serialize");
$.ajax({
type: "POST",
url: "http://localhost/frame/admin/pages/sort_items",
data: info,
context: document.body,
success: function(){
// alert("cool");
}
});
}
});
$( "#sortable" ).disableSelection();
我将url传递给我的控制器函数,我的加载了更新模型
和视图文件
{
echo '
' . $r->page_name . '
';}
?>
{
echo "There are no pages created yet";
}
?>
再次感谢你的提示卡米尔拉赫