公告
财富商城
积分规则
提问
发文
2019-06-27 21:49发布
Bombasti
is it possible to disable onclick="" while sorting?
I Have a working example here http://www.jsfiddle.net/V9Euk/59/
Peter
you can use start and stop options:
start
stop
$( ".selector" ).sortable({ start: function(event, ui) { ... }, stop: function(event, ui) { ... } });
Just create a flag and set to true when sorting started and to false when the sorting is over and in your onclick function check the flag first:
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')"
onclick="printAlert('sdfsdf')"
For more options look here
If you don't want to do it with a flag variable as per @nigative , you can do the following with 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; } });
最多设置5个标签!
you can use
start
andstop
options:Just create a flag and set to true when sorting started and to false when the sorting is over and in your onclick function check the flag first:
And of course your onclicks should look like
onclick="printAlert('sdfsdf')"
For more options look here
If you don't want to do it with a flag variable as per @nigative , you can do the following with the start and stop methods: