最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Why does my jQuery Mobile footer appear and then disappear when a user clicks the background? - Stack Overflow

programmeradmin3浏览0评论

I have a footer in my jQuery Mobile website.

<div data-role="footer" data-position="fixed">
    <div data-role="navbar">
        <ul>
            <li><a href="/page1">Page 1</a></li>
            <li><a href="/logout">Logout</a></li>
        </ul>
    </div>
</div>

In Google Chrome, when a user clicks on the background, the footer disappears. When the user clicks on the background again, the footer appears. Why? Is this an intentional feature?

I have a footer in my jQuery Mobile website.

<div data-role="footer" data-position="fixed">
    <div data-role="navbar">
        <ul>
            <li><a href="/page1">Page 1</a></li>
            <li><a href="/logout">Logout</a></li>
        </ul>
    </div>
</div>

In Google Chrome, when a user clicks on the background, the footer disappears. When the user clicks on the background again, the footer appears. Why? Is this an intentional feature?

Share Improve this question edited Dec 23, 2016 at 11:58 darryn.ten 6,9833 gold badges50 silver badges66 bronze badges asked Mar 28, 2012 at 19:23 John HoffmanJohn Hoffman 18.6k21 gold badges59 silver badges84 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 10

By default this is enabled. Here is some code to disable it in JQM v 1.1-RC1

$(document).on('pageinit','[data-role=page]', function(){
    $('[data-position=fixed]').fixedtoolbar({ tapToggle:false});
});

I like to bind it to the taphold event. It makes more sense to me. Here is how to do that:

$(document).on('taphold', '[data-role=page]', function(){
    $('[data-position=fixed]').fixedtoolbar('toggle');
});

If your using JQM v 1.0.1 then you can't use the .on() method. The on method is new as of jquery 1.7. Using .delegate() is remended over .live() so do this:

$(document).delegate('[data-role=page]','pageinit', function(){
    $.mobile.fixedToolbars.setTouchToggleEnabled(false);
});

The simple solution is to add the following attribute to your header:

data-tap-toggle="false"

...and the framework will take care of it for you.

See the Toolbar Widget's tapToggle option for more information.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论