jQuery UI自动完成需要在iOS上双击 [英] jQuery UI autocomplete needs double tap on iOS

查看:194
本文介绍了jQuery UI自动完成需要在iOS上双击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery UI自动完成功能(默认功能),但我在iOS中遇到问题 - 我需要点击两次才能选择一个选项。我在模态窗口中使用Bootstrap。有没有解决方法?

I am using jQuery UI autocomplete (the default functionality), but I am facing a problem in iOS - I need to tap two times to select an option. I am using it with Bootstrap inside a modal window. Is there any solution for this?

推荐答案

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

I have the same problem solved it by using the Focus event. First detect that they are on a touch device. You can expand on the user agents below for a more complete list.

然后在select事件中执行任何操作。这将通过一次点击重定向它们。

And then doing whatever you are doing inside the select event. This will redirect them with one tap.

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

这篇关于jQuery UI自动完成需要在iOS上双击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆