jQuery   发布时间:2022-04-19  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jquery-mobile – 谷歌地方自动完成与Jquery Mobile不在移动/触摸设备上工作大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
标题显示我正在使用 JQuery Mobile(1.3.0)构建移动网站,并且正在尝试实施Google Places Autocomplete(API v3)以帮助用户输入位置数据.

自动完成功能在桌面设备上正常运行,但在移动设备上使用时无法正常运行(我仅在iOS 6上进行过测试).

在移动设备上使用时,会显示相关位置的下拉列表,但是当您按下一个而不在地图上加载选择时,它就会消失.

我环顾四周,看到了一些可以看到z-index的解决方

作为罪魁祸首(见:http://osdir.com/ml/google-maps-js-api-v3/2012-01/msg00823.html).

我已经实现了这些修复,但无济于事,我不相信z-index是问题,因为我可以看到所选项目确实改变了它:在移动设备上按下时悬停状态/颜色.

如果有人有任何建议,我很满意,需要更多详情让我知道.

解决方法

谢谢Daniel.但我给出的解决方案会对性能产生一些影响.

我已经修改了FastClick库以实现这一点.

首先,我向FastClick构造函数添加一个参数,其中defaultElCls将是不应该实现fastclick的元素.

function FastClick(layer,defaultElCls) {
    'use Strict';
    var oldOnClick,self = this;

    this.defaultElCls = defaultElCls;

然后修改needsClick方法

FastClick.prototype.needsClick = function(target) {
'use Strict';
var nodename = target.nodename.toLowerCase();

if (nodename === 'button' || nodename === 'input') {

    // File inputs need real clicks on iOS 6 due to a browser bug (issue #68)
    // Don't send a synthetic click to disabled inputs (issue #62)
    if ((this.deviceIsIOS && target.type === 'file') || target.disabled) {
        return true;
    }       
} else if (nodename === 'label' || nodename === 'video') {
    return true;
}

return ((/\bneedsclick\b/).test(target.className) || (new RegExp(this.defaultElCls).test(target.className)));

};

然后将pac-item传递给FastClick构造函数

new FastClick(document.body,"pac-item");

希望FastClick库也会照顾这个:)

大佬总结

以上是大佬教程为你收集整理的jquery-mobile – 谷歌地方自动完成与Jquery Mobile不在移动/触摸设备上工作全部内容,希望文章能够帮你解决jquery-mobile – 谷歌地方自动完成与Jquery Mobile不在移动/触摸设备上工作所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。