views:

9

answers:

1
$('#element').draggable ({
    stop: function () {
        alert ('stopped');
        //do some action here
    }
}).trigger('stop');

nothing happens, thought #element is draggable now and event does execute after drag is complete. I tried .triggerHandle as well as 'dragstop' as eventtype, no luck

+1  A: 

Use this to trigger it instead:

.trigger('dragstop')

If you want it to behave completely as a normal event, use .bind('dragstop', function) to attach it as well, the start option behaves slightly differently.

Nick Craver
i tried, the same
selytch
@selytch - did you try using .bind()? The callback is treated a bit different than a straight bind being called is here.
Nick Craver
Thanks, that works! I did not realize .bind works differently. Is this documented? (probably yes...)
selytch
@selytch - nope, not well documented at all, just something you notice when loooking at the jQuery UI source, I agree it needs to be noted better somewhere.
Nick Craver