2
我想問,如何從document
中刪除事件處理程序,但只有那些具有命名空間的事件處理程序?解除與命名空間的一些事件處理程序
我有這段代碼,我沒有看到任何錯誤,但這個函數總是觸發mouseup
和touchend
的事件處理程序,即使在.unbind
之後。我確信我在這段代碼中有一些錯誤。
$(".inp").on("autocompleteresponse", function(event, ui) {
$(document).bind("mouseup.test, touchend.test", function(e) {
var container = $('.ui-autocomplete');
if (!container.is(e.target) && container.has(e.target).length === 0) {
if (ui.content.length > 0) {
ui.item = ui.content[0];
console.log (ui.item);
$(".inp").val(ui.item.label);
// This will fire always, on document click, should only once per time
$(document).unbind("mouseup.test, touchend.test");
}
}
});
});
感謝意見