无法阻止被动事件侦听器内的默认 [英] Unable to preventDefault inside passive event listener
本文介绍了无法阻止被动事件侦听器内的默认的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Framework7可排序列表并且效果很好,只是它没有更改列表时触发事件。
I'm using Framework7 sortable list and it works well, just that it doesn't trigger an event when the list is changed.
所以我正在尝试一些内置事件:
So I'm trying a few built-in events:
$('.sortable-handler').on('touchstart', function (e) {
e.preventDefault();
alert('touchstart');
});
$('.sortable-handler').on('touchmove', function (e) {
e.preventDefault();
console.log('touchmove');
});
$('.sortable-handler').on('touchcancel', function (e) {
e.preventDefault();
console.log('touchcancel');
});
$('.sortable-handler').mouseleave(function (e) {
e.preventDefault();
console.log('mouseleave');
});
..但我得到的是:
由于目标
被视为被动,因此无法阻止被动事件侦听器内的默认。请参阅
https://www.chromestatus.com/features/5093566007214080
我应该寻找哪种事件来获取每种类型的更新列表?
Which event should I look for to get the updated list on every sort?
推荐答案
当用户在新位置释放当前排序元素时,要处理Framework7中的可排序列表,您可以使用以下代码:
To handle sortable list in Framework7 when user release currently sorting element in new position, you can use this code:
$$('li').on('sortable:sort',function(event){
alert("From " + event.detail.startIndex + " to " + event.detail.newIndex);
});
小提琴: https://jsfiddle.net/0zf5w4y7/
这篇关于无法阻止被动事件侦听器内的默认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文