jqueryjquery-mobilejquery-mobile-button

Jquery Mobile 1.4 Beta 1 Back Button text


I'm trying to override the back button text for all back buttons in my jquery mobile 1.4 Beta 1 app.

My header snipit

<script src="~/Scripts/jquery-2.0.3.min.js" type="text/javascript"></script>
<script src="~/Scripts/Init.js" type="text/javascript"></script>
<script src="~/Scripts/jquery.mobile-1.4.0-beta.1.min.js" type="text/javascript"></script>

init.JS

$(document).bind("mobileinit", function () {
    $.mobile.defaultPageTransition = "slide";
    $.extend($.mobile, {
        loadingMessage: "My new loading label..."
    });
    $.mobile.page.prototype.options.backBtnText = "Volver";
});

When I check $.mobile.page.prototype.options.backBtnText is is set correctly as documented here http://view.jquerymobile.com/1.4.0-beta.1/dist/demos/toolbar/ but the back button still says "Back".

Not sure if I'm setting it to late as this guy http://blog.moldoveanu.net/2010/11/jquery-mobile-translating-the-back-and-loading-labels/ shows doing it this way on an old version or is this possibly a 1.4 beta bug?


Solution

  • jQuery Mobile 1.4 Beta

    As per the changes in Alpha, data-add-back-btn is added to toolbar not page div. So you need to override $.mobile.toolbar options, not $.mobile.page.

    Unlike previous versions, data-add-back-btn is added to page div.

    Demo

    $(document).on("mobileinit", function() {
      $.mobile.toolbar.prototype.options.addBackBtn = true;
      $.mobile.toolbar.prototype.options.backBtnText = "Volver";
    });
    

    Reference: Change - Alpha 1