2009-09-28 24 views
1

当我尝试使用可排序的事件。如何使用jQuery UI排序停止事件?

$('.selector').bind('sortstop', function(event, ui) { 
    ... 
}); 

而不是

$('.selector').sortable({ 
    stop: function(event, ui) { ... } 
}); 

是否有缺少的部分在此:(例如在stop()事件),它只有当我使用绑定它的工作原理?

我问的唯一原因是因为当我使用实际的bind()方法进行绑定时,它不允许我访问我传入的事件或ui参数。我总是返回undefined。

+0

@colourandcode你能工作吗? – mcgrailm 2010-04-23 12:51:42

回答

1

Hrm,如果你的函数的参数是未定义的值,那么这听起来像一个错误。要回答您的具体问题,您的第二行($('.selector').sortable({ stop: function(event, ui) { ... } });)在第一次初始化致sortable()后将不起作用。该初始化调用后更改选项时,可以调用option方法:

$('.selector').sortable('option', 'stop', function(event, ui) { /* ... */ }); 
0

例如使用排序

$('.selector').sortable({ 
    change: function(event, ui) { 
     ui.placeholder.parent().children().show(); 
     ui.placeholder.parents("li:first").find(".sortaccordion:first").attr('src',prefix+'/img/accordionopen.gif'); 
    }, 
    stop: function(event, ui) { 
     // do stuff here 
    } 
}); 

如果这不起作用,那么也许你有你喜欢不加载一些其他的问题你可以排序或你有坏的HTML

你有什么错误?