views:

343

answers:

2

When I try to use a sortable event . (For instance the stop() event) It only works when I bind it using :

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

rather than

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

Is there a missing piece in this?

The only reason I ask is because when I bind using the actual bind() method it's not giving me access to the event or ui parameters I pass in. I'm always returned undefined.

A: 

Hrm, if the parameters to your function are undefined values then that sounds like a bug. To answer your specific question, your second line ($('.selector').sortable({ stop: function(event, ui) { ... } });) will have no effect after the first, initializing call to sortable(). To change options after that initializing call, you call the option method:

$('.selector').sortable('option', 'stop', function(event, ui) { /* ... */ });
Ken Browning
A: 

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 ?

mcgrailm