$('div.something').sortable(options)
works fine, but breaks after $('div.something').unbind();
. Attempting to re-run $('div.something').sortable(options);
or $('div.something').sortable('refresh');
after $('div.something').unbind();
does not help.
I am using $.unbind to deactivate/un-initiate a plugin by removing the events from the element that the plugin is being applied on, however this technique is having an adverse effect in that it is breaking $.sortable. Any ideas on how re-activate sortable?
I am using the latest versions of jQuery and jQuery UI.
Making a call to .sortable('destroy')
prior to calling .unbind()
will completely remove the sortable feature from the element.
This ensures proper tear-down before performing the somewhat dangerous call to .unbind()
, which removes all bound handlers on the element. Then, you can re-initialize the sortable feature.
// Initialization of the sortable feature
$('div.something').sortable(options);
...
// Remove the sortable feature to prevent bad state caused by unbinding all
$('div.something').sortable('destroy');
// Unbind all event handlers!
$('div.something').unbind();
...
// Re-initialize the sortable feature
$('div.something').sortable(options);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With