【问题标题】:Why is sort the only event firing for jQuery UI .sortable()?为什么排序是 jQuery UI .sortable() 的唯一事件触发?
【发布时间】:2010-12-17 02:48:29
【问题描述】:

我有一个简单的代码示例@http://jsbin.com/ukiwo3/edit

它有 2 个连接列表和大量绑定事件。我希望我错过了一些基于http://jqueryui.com/demos/sortable/ 事件的简单事件我想当我拖动并重新排序问题时我应该看到所有这些事件被触发。目前只将日志排序到控制台。

谁能告诉我出了什么问题以及如何让其余的开火?

谢谢, 丹尼斯

【问题讨论】:

标签: javascript jquery jquery-ui jquery-ui-sortable


【解决方案1】:

绑定时事件的名称不同,例如sortstart 而不是startLook at the list of events on the demo page 获取绑定的完整列表。

总的来说,it should look like this:

$( ".questions" ).bind( "sortstop", function(event, ui) {
  console.log("stop event");
});
$( ".questions" ).bind( "sortstart", function(event, ui) {
  console.log("start event");
});
$( ".questions" ).bind( "sortchange", function(event, ui) {
  console.log("change event");
});
$( ".questions" ).bind( "sort", function(event, ui) {
  console.log("sort event");
});
$( ".questions" ).bind( "sortremove", function(event, ui) {
  console.log("remove event");
});
$( ".questions" ).bind( "sortout", function(event, ui) {
  console.log("out event");
});
$( ".questions" ).bind( "sortover", function(event, ui) {
  console.log("over event");
});
$( ".questions" ).bind( "sortupdate", function(event, ui) {
  console.log("update event");
});

(未优化,仅显示事件名称)

【讨论】:

  • 我知道我只需要第二双眼睛!应该是自己发现的。干杯
【解决方案2】:

我这样做了,我看到触发了停止事件:

$('.questions').sortable({ 
        axis: 'y', 
        connectWith: ".questions",
        placeholder: "question-highlight",
        stop:function(event, ui) {
         console.log("stop event");
        }
});

在我看来,这些“事件”无法通过 bind 访问。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-09
    • 2010-11-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多