繁体   English   中英

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

[英]How do I make a ajax-loaded UL sortable in a JQuery UI dialog?

我需要在后台加载UL,然后将其显示在对话框中进行排序,但是我对JQuery / JQuery UI并不陌生,显然在使用Google时遇到了麻烦。 据我所知:

$(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();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM