ios的webkit touchend事件不发射?

我试图实现一个基于IOS的webkit的应用程序的菜单,其中用户触摸/点击并保存菜单button('.menu_item'),在子菜单打开(div.slide_up_sub_menu)500毫秒后,用户应该能够将他们的手指/鼠标滑动到子菜单项目并释放。

<li class="menu_item"> ASSET MANAGEMENT <div class="slide_up_sub_menu hidden_menu"> <ul class="submenu"> <li>Unified Naming Convention</li> <li>Version Control</li> </ul> </div> </li> 

然后,应用程序应该能够检测touchend / mouseup事件发生在哪个子菜单项上。 我将一个touchstart事件绑定到菜单项,等待500ms,然后告诉子菜单显示。 当用户松开手指时,触发事件应该触发closures子菜单。 如果用户已经停止了对子菜单项的触摸,则应该检测到它。 目前,在桌面上的Safari中检测哪个子菜单项发生mouseup事件:

 $('ul.submenu li').live('mouseup', function(e){ console.log($(e.currentTarget)); //works on the desktop }); 

但如果我使用touchend处理程序执行相同的操作,则无法在ipad上运行:

 $('ul.submenu li').live('touchend', function(e){ console.log($(e.currentTarget)); //never fires }); 

如果我查找每个touchend事件,当我结束子菜单项的触摸时,可以获得对父子菜单项的引用:

 $(document.body).bind('touchend', function(e) { console.log($(e.target).html()); //logs ASSET MANAGEMENT }); 

但没有提及子菜单项。

有没有人有任何想法,为什么touchend事件不被触发的子菜单项?

谢谢

touchend不会触发,因为touchcancel已经发射了。 如果你想要全面的处理你需要打电话

 e.preventDefault() 

在“touchmove”事件的callback中,否则当浏览器判断这是滚动事件时发生touchmove事件时,将触发touchcancel并且不会触发touchend。

也许有点晚回答。 这个事件永远不会发生,因为触发事件触发了触发事件发生的元素。 所以,要做你想做的事情,一个解决scheme是使用document.elementFromPoint方法,你将发送适当的x和y坐标。

如果你不需要使用多点触控数据,你可以继续在ipad上使用鼠标。

进一步阅读: http : //developer.apple.com/library/IOS/#documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html