1

当我尝试使用可排序事件时。(例如stop()事件)它仅在我使用以下绑定时才有效:

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

而不是

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

这里面有没有遗漏的部分?

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

4

2 回答 2

1

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

$('.selector').sortable('option', 'stop', function(event, ui) { /* ... */ });
于 2009-09-28T18:58:47.260 回答
0

example use of sortable

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

if this doesn't work then maybe you are having some other problem like your not loading ui sortable or you have bad html

do you get any errors ?

于 2010-04-21T18:29:53.027 回答