[心缘地方]同学录
首页 | 功能说明 | 站长通知 | 最近更新 | 编码查看转换 | 代码下载 | 常见问题及讨论 | 《深入解析ASP核心技术》 | 王小鸭自动发工资条VBA版
登录系统:用户名: 密码: 如果要讨论问题,请先注册。

[备忘]jquery mobile,phonegap,ios,文本框获得焦点时,footer navbar漂浮在页面中间

上一篇:[备忘]ios开发,app icon 图标大小的问题
下一篇:[备忘]javascript保留两位小数,xx.toFixed(2)

添加日期:2015/2/22 8:01:00 快速返回   返回列表 阅读3881次
jquery mobile,phonegap,弄ios版本时,

用户注册页面,有多个下拉框选择区域,

当点击下拉框时,页面一憋,却貌似后退了一下,

看后台log,发现访问了购物车页面,而该页面检查了用户是否登录

未登录跳转到登录页面,

所以表面看起来,是从注册页面跳回了登录页面。
-------------------------------
百思不得其解,铁定不是后台的问题,

但是前台我点击下拉框,应该出现选择那个界面啊,怎么会无缘无故点击了连接了,

在select框上加了onclick事件,发现没有触发,

那么说明不是js的问题。

开始怀疑是jquery mobile封装select框后在ios下有问题,

一顿google,没有类似的问题

苦恼~睡觉~~
----------------------------------
边睡觉,边想~~

我有一个footer的navbar,即底下的导航条,有4个栏目,

最右边两个是“购物车”,“我的”,

既然后台显示app访问了购物车,说明真的点了这个链接,

我没点,那么应该是系统怎么弄错了,点到了
-------------------------------------
早上爬起来,直接把footer里的链接里加了onclick事件,

果然,我点击下拉框时,触发了购物车的onclick事件,

我又给onclick最后加了return false,终于看到罪魁祸首了~~

点击下拉框后,ios在屏幕最底端显示了滚轮式的那种选择界面,

而在那瞬间,我的footer飘起来了,正好盖在那个下拉框上,

然后ios估计有个点击动作,或者就是我的点击动作,在footer上触发了,

正好点在了购物车上。
-----------------------------------------
其实,footer有时候会飘起来,我早发现了,但没啥影响,

以为jquery mobile就这样,也就没管他。

但现在影响了,所以就得像个办法不让它乱飘~~

google,关键字用的:jquery mobile ios navbar float

终于有类似的了
---------------------------------------------
Footer navbar moves up when clicking on a textbox 
https://getsatisfaction.com/apperyio/topics/footer_navbar_moves_up_when_clicking_on_a_textbox
最后按这个方法解决的。

供参考:


    <div data-role="footer" data-position="fixed" data-id="footer" data-theme="d">
        <div data-role="navbar">
            <ul id="bottomBar">
                <li><a id="homeBar" href="${ctx}/mobile/" data-role="button" data-icon="home" data-ajax="false">首页</a></li>
                <li><a id="pSortBar" href="${ctx}/mobile/listNodeByLevel?treeId=1" data-role="button" data-icon="bullets" data-ajax="false">分类</a></li>
                <li><a id="cartBar" href="${ctx}/mobile/cart/list" data-role="button" data-icon="shopping-cart" data-ajax="false">购物车</a></li>
                <li><a id="myBar" href="${ctx}/mobile/user/home" data-role="button" data-icon="user" data-ajax="false">我的</a></li>
            </ul>
        </div>
    </div>
    <script>
    //文本框等获得焦点时,虚拟键盘会显示出来,footer可能会漂浮在页面中间,
    //遮挡页面,或触发点击事件,故需要判断高度,必要时隐藏footer
    var portraitScreenHeight;
    var landscapeScreenHeight;
    if(window.orientation === 0 || window.orientation === 180){
        potraitScreenHeight = $(window).height();
        landscapeScreenHeight = $(window).width();
    }
    else{
        portraitScreenHeight = $(window).width();
        landscapeScreenHeight = $(window).height();
    }
    var tolerance = 25;
    $(window).bind('resize', function(){
        if((window.orientation === 0 || window.orientation === 180) &&
        ((window.innerHeight + tolerance) < portraitScreenHeight)){
            $("[data-role=footer]").hide();
        }
        else if((window.innerHeight + tolerance) < landscapeScreenHeight){
            $("[data-role=footer]").hide();
        }
        else{
            $("[data-role=footer]").show();
        }
    });
    </script>



其它几个url可以看看:
https://forum.jquery.com/topic/how-to-set-footer-fixed-at-bottom-even-if-virtual-keyboard-is-open
https://github.com/jquery/jquery-mobile/issues/4113
http://stackoverflow.com/questions/13097663/jquery-mobile-fixed-footer-is-moving-when-the-keyboard-appears
http://stackoverflow.com/questions/11600040/jquery-js-html5-change-page-content-when-keyboard-is-visible-on-mobile-devices
http://stackoverflow.com/questions/6861764/jquery-mobile-stick-footer-to-bottom-of-page
 

评论 COMMENTS
没有评论 No Comments.

添加评论 Add new comment.
昵称 Name:
评论内容 Comment:
验证码(不区分大小写)
Validation Code:
(not case sensitive)
看不清?点这里换一张!(Change it here!)
 
评论由管理员查看后才能显示。the comment will be showed after it is checked by admin.
CopyRight © 心缘地方 2005-2999. All Rights Reserved