jQuery可排序-创建时

jQuery可排序-创建时,jquery,Jquery,创建sortable/Portlet后,我需要根据从数据库中保存的内容设置位置。所以我的问题是,如何才能完成这样的任务 当用户使用以下内容选择他们的首选项时,我有以下内容来更新位置,我知道可排序类上有一个create方法,但不确定如何从数据库中获取要显示的位置 $( ".column" ).sortable({ connectWith: ".column", handle: ".portlet-header", cancel: ".portlet-

创建sortable/Portlet后,我需要根据从数据库中保存的内容设置位置。所以我的问题是,如何才能完成这样的任务

当用户使用以下内容选择他们的首选项时,我有以下内容来更新位置,我知道可排序类上有一个
create
方法,但不确定如何从数据库中获取要显示的位置

$( ".column" ).sortable({
        connectWith: ".column",
        handle: ".portlet-header",
        cancel: ".portlet-toggle",
        placeholder: "portlet-placeholder ui-corner-all",

        update: function(event, ui) {

            // identify handle for item
            var handle = ui.item.find(".portlet-header");

            // get current html of handle
            var html = handle.html();


            var data = $('.column').sortable( "serialize", { attribute: "sort" } );

            // ajax call
            $.ajax({
                url:        '/api/portlets/update',
                data:       { position: ui.item.index() },
                type:       'POST',
                success: function(response, ui) {

                    console.log('Success ');

                },
                error: function(response) {
                    console.log('Error!');

                }
            });
        }
目前我有两个Portlet,数据库如下所示:


有人愿意在这方面帮助兄弟吗?你是说你想根据从数据库检索的记录的
order
属性,按顺序显示排序表中的项目吗?为什么不在DB查询本身中或通过API方法应用排序呢?两者似乎都比事后在客户端这样做更有效。我希望加载时项目在DB中的显示顺序,或者如果portlet id 1在顺序位置1(第2位),页面加载时应该在位置1(第2位)显示。