Enable/Disable auto back button in jQuery Mobile framework


Hi,

Currently JQuery Mobile is still in alpha version. As they are moving towards first beta version, they do some changes from previous alpha versions.

One of the key change is, they disable auto back button by default, As they thought that many of the mobile device will have back button. But some may not have. To enable it, use the following option:

Please note that sequence of adding library does matter here.

<script src="/javascript/jquery.min.js"></script>
<script type="text/javascript">
    $(document).bind("mobileinit", function(){
        $.mobile.page.prototype.options.addBackBtn= true;
    });
</script>
<script src="javascript/jquery.mobile.js"></script>

Advertisements

6 thoughts on “Enable/Disable auto back button in jQuery Mobile framework

  1. Farid Wardan

    From the official documentation:

    jQuery Mobile has a feature to automatically create and append “back” buttons to any header, though it is disabled by default. This is primarily useful in chromeless installed applications, such as those running in a native app web view. The framework automatically generates a “back” button on a header when the page plugin’s addBackBtn option is true. This can also be set via markup if the page div has a data-add-back-btn=”true” attribute.

    Works fine!

    http://jquerymobile.com/demos/1.0b2/#/demos/1.0b2/docs/toolbars/docs-headers.html

    Reply
    1. Vikas Post author

      Thanks for the additional information. I started with jQuery Mobile when it was in its first alpha version, so things are volatile. Can’t keep myself checking whether it is proper or not. Anyway that’s why we share the knowledge.

      Reply

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s