如何在JQueryUI对话框中使加载ajax的UL可排序



我需要在后台加载一个UL,然后将其显示在一个对话框中进行排序,但我是JQuery/JQuery UI的新手,显然在谷歌方面遇到了问题。这是我所掌握的:

$(document).on('click','a.priority', function(){
    // Get the URL of the link
    var href = $(this).attr('href');
    // Tell the page to expect JS instead
    href = href + "/ajax";
    // Get the page content
    $.get(href, function(data){
        // Initialise a dialog for the content
        var my_dialog = $('<div></div>')
            .dialog({
                 autoOpen: false
                ,open: function (event, ui) {
                    // Add the result of the GET (a UL) as the dialog's content
                    my_dialog.html(data);
                    // Make it sortable, how?
                    my_dialog.sortable().disableSelection();
                    // Set the dialog title (this will be dynamic later, and we might need to call a single dialog that gets remangled rather than creating one every time)
                    my_dialog.dialog("option","title","Change priority");
                }
            });
        // Show the dialog
        wsd_dialog.dialog('open');
    });
    // Don't follow the link
    return false;
});

这将获取内容(需要排序的项目的UL)并将其显示在对话框中,但UL显示为单个"可排序"元素。

如何使UL的LI子代可排序,而不是UL本身?

有一种感觉,这是一个愚蠢的问题,我一定是错过了一些文件。

看起来您正在对话框中调用sortable()。您需要在对话框中选择列表项,并在这些项上调用sortable()

my_dialog.find('ul').sortable();

最新更新