我对这个问题束手无策
这里的想法是防止链接工作,直到脚本完成其工作并再次启用链接。
我正在使用现场,不打算改变它。下面的脚本可以在没有 live 的情况下工作,但不能在 live 的情况下工作。你能看出为什么吗?
$(document).ready(function () {
$('.user').live('click',function() { // All works well if live is removed.
//But I need live, since things change and there's a lot of old code using it.
console.log('Invoked');
// Do anything to disable the link
$('.user').unbind('click'); // Does not work
//$('.user').off('click'); // Does not work either
//Once the script is done with its ajax work, enable it again
//$('.user').bind('click');
//$('.user').on('click');
});
});
<div class="container">
<div><i class="icon-add user"></i></div>
<div><i class="icon-add user"></i></div>
<div><i class="icon-add user"></i></div>
<div><i class="icon-add user"></i></div>
</div>