05
2011Adding & Customizing Back Buttons in jQuery Mobile Framework

jQuery Mobile Framework has a feature to automatically create and append “back” buttons to any application header, although it is disabled by default. The jQuery Mobile framework automatically adds a “back” button on a header when the page plugin’s addBackBtn option is true. You can also enable this feature via markup by setting page div a data-add-back-btn=”true” attribute.
Converting Links to Back Button
If you add the attribute data-rel=”back” on any anchor, any clicks on that anchor will effectively become the back button, going back one history entry and just ignoring the anchor’s default href link, you can create a cancel button like this:
<a data-role="button" data-rel="back">Cancel</a>
Also note that if you just want a reverse transition without actually going back in history, you should use the data-direction=”reverse” attribute instead.
Customizing the Back Button Text
If you want to configure the back button text, you can either use the data-back-btn-text=”previous” attribute on your page element, or set it programmatically via the page plugin’s options:
$.mobile.page.prototype.options.backBtnText = "previous";
Hope that helps.
Cheers!
While working on jQuery Mobile Framework project, I had already used Prototype library for some features in the application. But jQuery and Prototype refused to play ball and application broke.
Recent Comments
(7 hours ago)
(7 hours ago)
(1 days ago)
(1 days ago)
(1 days ago)
(1 days ago)
(1 days ago)
(1 days ago)
(1 days ago)
(1 days ago)