jQuery UI 自动完成需要在 iOS 上双击

Bry*_*e77 5 javascript iphone jquery-ui ipad twitter-bootstrap-3

我正在使用 jQuery UI 自动完成(默认功能),但我在 iOS 中遇到问题 - 我需要点击两次才能选择一个选项。我在模式窗口内将它与 Bootstrap 一起使用。有什么解决办法吗?

Dar*_*sor 2

我有同样的问题,通过使用 Focus 事件解决了它。首先检测它们是否位于触摸设备上。您可以展开下面的用户代理以获得更完整的列表。

然后在 select 事件中做你正在做的事情。只需轻轻一按即可重定向它们。

   focus: function (event, ui) {
   if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
       window.location.href = ui.item.url;
   } else{
     $('#SearchTerm').val(ui.item.label)
   }
}
Run Code Online (Sandbox Code Playgroud)