Jquery Sortable - disable onclick = "" when sorting

Is it possible to disable onclick = "" when sorting?

I have a working example here http://www.jsfiddle.net/V9Euk/59/

Peter

+4
source share
2 answers

If you do not want to do this with the flag variable according to @nigative, you can do the following using the start and stop methods:

$("#lop").sortable({ revert: '100', placeholder: 'auo', start: function(event, ui) { ui.item[0].oldclick = ui.item[0].onclick; ui.item[0].onclick = null; }, stop: function(event, ui) { ui.item[0].onclick = ui.item[0].oldclick; } }); 
+1
source

you can use the start and stop options:

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

Just create a flag and set it to true when sorting starts and false when sorting is over, and in your onclick function, first check the flag:

 var isBeingSorted = false $( ".selector" ).sortable({ start: function(event, ui) { isBeingSorted = true; }, stop: function(event, ui) { isBeingSorted = false; } }); function printAlert(message){ if(!isBeingSorted) alert(message); } 

And, of course, your onclicks should look like onclick="printAlert('sdfsdf')"

For more options, see here.

+3
source

All Articles