LLLLLLL Posted November 7, 2013 Share Posted November 7, 2013 I'm using http://api.jqueryui.com/sortable/ and I'd like my table to be unsortable by default, a user clicks something, and then it's sortable, then they click something else and it's not sortable. I thought I could use these two functions: function enable_sort() { $( ".btf_table tbody:first" ).sortable({ helper: fixHelperModified, stop: updateIndex, axis: "y" //handle: '.handle' }).disableSelection(); } function disable_sort() { $( ".btf_table tbody:first" ).off(); } I can use them, but then I cannot use "enable_sort" again after "disable_sort" is called. I'm sure I'm mis-uisng the "off" function but I'm not sure what I'm supposed to be calling instead, or with which parameters. Quote Link to comment https://forums.phpfreaks.com/topic/283701-enabledisable-events/ Share on other sites More sharing options...
Solution requinix Posted November 7, 2013 Solution Share Posted November 7, 2013 You should probably be using the enable/disable methods. Set up the sorting at the start and then disable it immediately (since that's the default). Then enable/disable as needed. Quote Link to comment https://forums.phpfreaks.com/topic/283701-enabledisable-events/#findComment-1457437 Share on other sites More sharing options...
LLLLLLL Posted November 7, 2013 Author Share Posted November 7, 2013 Yes, that definitely works, thanks. But in general, let's say no "enable/disable" option exists, how would I add and remove (in this case) the "sortable" function? Just curious for future reference. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/283701-enabledisable-events/#findComment-1457439 Share on other sites More sharing options...
requinix Posted November 7, 2013 Share Posted November 7, 2013 destroy method to remove, then re-add when you want it. But enable/disable is still the best option. Quote Link to comment https://forums.phpfreaks.com/topic/283701-enabledisable-events/#findComment-1457445 Share on other sites More sharing options...
LLLLLLL Posted November 7, 2013 Author Share Posted November 7, 2013 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/283701-enabledisable-events/#findComment-1457446 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.