我尝试使用 YUI 3 在"后退"按钮上分离一个 'touchstart' 元素。
但没有什么是分离的。当我触摸"后退"按钮时,两个函数都被调用。
这是我的代码:
Y.all('.back').detachAll('touchstart');
Y.all('.back').on('touchstart',function(e){
alert('types');
loadMainframe(myURL);
e.preventDefault();
});
Y.all('.back').detachAll('touchstart');
Y.all('.back').on('touchstart',function(e){
alert('resto');
loadMainframe(myURL);
e.preventDefault();
});
好的,我找到了。
只能分离正在使用的 Y 元素的事件。
我使用了全局元素
YEvent = YUI().use('node','touch-event');
现在我在 YEvent 元素上制作我的 detach() 和 on(),它正在工作。