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");
}
}
});
});
感谢意见