使用jQuery Mobile的注意事项(译)

时间:2015-02-24 01:50:34   收藏:0   阅读:2492

翻译编辑自:http://www.appnovation.com/blog/7-things-know-about-jquery-mobile-working-it

一、Android和IOS的内置键盘(Native keyboard)是不一样的

对手机的内置键盘的操作是比较复杂和富有争议的,不同的手机可能需要不同的css。Android使用的是第三方的键盘插件(3rd party keyboards ),如 Google Keyboard 和 SwiftKey

可设置input的type属性来决定内置键盘是显示数字键盘还是显示字母键盘(参考link):

技术分享

技术分享

技术分享

需要说明的是:

二、page events的顺序

如从A页面转到B页面(Navigate from A to B)

三、jQuery Mobile transitions

jQuery Mobile的页面转换常会出现Flickering/Blinking烁问题,为此可以在viewport meta tag中关闭(disabling)jQuery Mobile的页面转换。

四、 Fixed Header and Footer

jQuery Mobile内置有固定位置的header和footer,但一些低版本的Android和IOS不支持,需要另外修正

1)加data-tap-toggle="false"到header和footer

2) 如IOS 6, 7 ,8的hack如下

if (iOS()) {
    $(document).on(‘blur‘, ‘input:not(:submit), select, textarea‘, function () {
        var paddingBottom = parseFloat($(".ui-mobile-viewport, .ui-page-active").css("padding-bottom"));
        $(".ui-mobile-viewport, .ui-page-active").css("padding-bottom", (paddingBottom + 1) + "px");
        window.setTimeout(function () {
            $(".ui-mobile-viewport, .ui-page-active").css("padding-bottom", paddingBottom + "px");
        }, 0);
    });
}

var iOS() = function () {
    var userAgent = window.navigator.userAgent.toLowerCase();
    return (/iphone|ipad|ipod/).test(userAgent);
}

3)或参见:JQueryMobile - fixed footer not fixed after input focus

$(‘div:jqmData(role="page")‘).on(‘pageinit‘,function(){
    $(document)
        .on(‘focus‘,‘input, select, textarea‘, function(){
            $(‘[data-role="footer"][data-position="fixed"]‘).hide();
        })
        .on(‘blur‘,‘input, select, textarea‘,function(){
            $(‘[data-role="footer"][data-position="fixed"]‘).show();
        });
});

有时候当toolbar滚动过快的时候会导致不平滑问题。

五、更多的Javascript的Events

参考: http://forum.jquery.com/topic/mobile-events-documentation

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!