看看这个:http://jsfiddle.net/9c4xG/
$('.container').on('change.namespace focusout.namespace', '.item', function(event) {
$('<p>', {
'text': 'event: ' + event.type
}).appendTo('.container');
});情况1:如果在输入时按Tab键-触发一个事件(focusout);情况2:如果你在输入中键入任何单词并按Tab键-触发两个事件(focusout,change);
当第一个事件被触发时,如何阻止案例2中的所有类似事件。
有没有一种通用的方法来只使用这些事件中的一个(focusout,change,..)如果触发了多个?并为命名空间或当前处理程序禁用其他。
抱歉,愚蠢的英国式英语。
发布于 2013-10-22 23:18:04
使用标志作为信号量...
$('YourInput').on('events',function(e) {
var t = $(this), data = t.data('flag') || false;
if (data) {
return;
}
// Locking semaphore
t.data('flag', true);
// Your code here
// Free semaphore
t.data('flag', false);
});发布于 2013-10-22 23:19:25
AFAIK唯一的办法就是自己处理:
$('selector').on('events', function() {
if ($(this).data('handling-event')) {
return;
}
$(this).data('handling-event', true);
.... code here ....
$(this).data('handling-event', null);
});https://stackoverflow.com/questions/19521743
复制相似问题