我正在一个移动网站上工作,当我不希望他们遇到事件时,我正在努力工作。如何防止dragend后的touchend事件?
为了简单起见,这是写像这样(jQuery中):
el.on('touchend', function(ev) {
ev.preventDefault();
// fire an ajax call
};
但是,有时滚动页面,当用户将达到该项目,导致Ajax请求开火(从而改变页面状态)。
我想不出一种解决方法(ev.stopPropagation()无效),所以我决定观看dragstart和dragend事件。
el.on('dragstart', function() {
el.off('touchend');
});
el.on('dragend', function(ev) {
ev.stopPropagation(); // <-- seems to do nothing
// add back the event above (the function is set to a var)
});
如果我的touchend回调内部提醒,我得到确认的是,touchend事件实际上是火做后,我拖着停止。
有没有人有任何想法如何防止任何其他事件发射?我希望我只是失明而错过了一些明显的东西。
在此先感谢!