【问题标题】:how can i sort elements on drop using JQuery UI?如何使用 JQuery UI 对放置的元素进行排序?
【发布时间】:2015-12-07 11:44:00
【问题描述】:

我的'li' 元素很少。我可以拖放元素...但是,我的要求是我需要在放置后对元素进行排序(释放鼠标后元素必须移动到目的地)。请帮我... 这是我正在使用的代码,

$( ".sortable" ).sortable({
    revert: true,
    start : function(e){
        console.log(e);
    }
});
$( "li selector" ).draggable({
    connectToSortable: ".sortable",
    start : function(e){
        console.log(e);
    }
});

【问题讨论】:

    标签: javascript jquery jquery-ui drag-and-drop jquery-ui-sortable


    【解决方案1】:

    是否没有onDrop 事件或您可以监听的类似事件,然后运行您的排序功能?

    如果没有,您可以运行一个绑定到 jQuery 事件 .mouseup() 的函数,然后触发您的排序函数。

    https://api.jquery.com/mouseup/

    【讨论】:

    • 我需要在拖动时停止'li'移动效果......我需要在移动时显示一个方形虚线框而不是'li'元素。
    • jsfiddle.net/IrvinDominin/RmLAA 在这个链接中,“Element1”随着光标移动,但我需要显示一个虚线方框而不是“Element1”,它必须在鼠标释放后进行排序。跨度>
    猜你喜欢
    • 2020-11-03
    • 1970-01-01
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    • 2020-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多