The localization feature in jQuery mobile is causing the button style to disappear

For my current project, I am utilizing the jquerymobile framework along with the i18Next localization library.

Here is the HTML code snippet:

<div id="messageboxPage" data-role="page" data-theme="a">
        <div data-role="header" data-theme="a"></div>
        <div id="messagePage" data-role="content" data-theme="a">
            <div class="barContainer" id="barContainer">
                <div class="ui-bar ui-bar-b  ui-btn-corner-all" style=" margin-top: 40px; padding-left: 0px;padding-right:10px; ">
                    <div style="float: left;  width: 30%;"> <a href="#" id="aNo" onclick="SetActive('aNo')" class="LnkButton" data-theme="a" data-role="button" data-inline="true" data-mini="true">Cancel</a> 
                    </div>
                    <div style="float: left;   width: 30%;padding-left: 6%; padding-right: 2%;"> <a href="#" id="aAccept" onclick="Supprimer();" data-theme="a" class="LnkButton" data-role="button" data-inline="true" data-mini="true">Delete</a> 
                    </div>
                    <div style="float: right; width: 30%;"> <a href="#" id="aReply" onclick="Reply();" data-theme="a" class="LnkButton" data-role="button" data-inline="true" data-mini="true">Reply</a> 
                    </div>
                </div>
            </div>
        </div>
    </div>

And here is the corresponding JavaScript code:

window.opts = {
         lng: 'fr',
         getAsync: true,
         ns: {
             namespaces: ['ns.controls'],
             defaultNs: 'ns.controls'
         },
         useLocalStorage: false,
         debug: true
     };
     $.i18n.init(opts).done(function () {
         alert('i18n init function');
         $('#aNo').text("No Merci!");
         $('#aAccept').text("Supprimer");
         $('#aReply').text("Respondre");
         $('#messageboxPage').trigger('pagecreate');
     });
    
     $(document).ready(function () {
         alert('messagebox document ready');
     });

The main issues at hand are that the button styles are being lost when text changes and setting text labels has not been successful even after triggering page creation. Any suggestions on how to address these problems?

To view a working demonstration, check out this JS Fiddle.

Answer №1

To update the text on a button, simply change the content of the .ui-btn-text element. This method is much more efficient than using the span > span approach:

$('#aNo .ui-btn-text').text("No Merci!");
$('#aAccept .ui-btn-text').text("Supprimer");
$('#aReply .ui-btn-text').text("Respondre");  

Check out this Fiddle for demonstration

Answer №2

it did the trick for me

$.i18n.init(opts).done(function () {
     alert('i18n initialization function');
     var message_type = 0;
     if (message_type == "0") {
         alert('from 0');
         $('#lblTo').text("from 0");
     } else if (message_type == "1") {
         alert('to 1');
         $('#lblTo').text("to 1");
     } else if (message_type == "2") {
         alert('from 2');
         $('#lblTo').text("from 2");
     }

     $('lblDate').text($.t('Messagebox.lblDate'));
     $('lblSubject').text($.t('Messagebox.lblSubject'));


     //////////////////////////this is where i made a mistake
     $('#aNo > span > span').text("No Thanks!");
     $('#aAccept > span > span').text("Delete");
     $('#aReply > span > span').text("Reply");
     ///////////////////////////

     $('#messageboxPage').trigger('pagecreate');
 });

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Clicking to enter fullscreen mode on a website will result in the Fullscreen API automatically closing

For my current project, I am creating an offline website and would like it to display in full screen when opened. I have been using the Fullscreen API, but it exits fullscreen mode when a user navigates to another page. After researching the issue, it seem ...

What is the best way to insert a hint into an asp:textbox?

Is there a method to insert a hint or placeholder text within an asp:TextBox element? I am looking for a way to have text appear in the textbox that disappears when the user clicks on it. Can this be done using html / css? ...

loading xml data into a table partially using jquery

Currently, I am utilizing AJAX to load and parse XML data. I have constructed a table where I am inserting the data from the XML using a loop. The issue lies in the fact that only around 3000 rows are being inserted into the table even though the XML conta ...

Exploring the Power of jQuery Ajax Requests

Currently, I am making an Ajax call from site.com/users/{username} I need to access the url site.com/account/deleteComment, but when I check in fireBug it seems to be trying to access site.com/users/account/deleteComment Below is the code snippet: $ ...

Is it possible to create repetitive events using loops in jQuery?

When it comes to specificity in coding... $("#ht_1").click(function () { alert("hello"); }); $("#ht_2").click(function () { alert("hello"); }); // here's what I attempted for (i = 1; i <= 2; i++) { $("#ht_" + i).click(function () { ...

Disable the movement and dragging functionality of the scroll feature in Google Maps using React

I have a map.jsx file in my React application that contains the code below: import React from 'react'; import GoogleMapReact from 'google-map-react'; import './map.css'; const Map = ({ location, zoomLevel }) => ( <d ...

Align the button to the right within the form

Having difficulty aligning a button to the right using float: right; No matter what I try, the button with the "advanced-search-button" class refuses to move to the right. This issue is occurring in Bootstrap 4. HTML <link href="https://maxcdn. ...

My goal is to utilize CSS grid to craft a unique layout by establishing a grid area. However, the layout is not functioning as anticipated

Currently, I am in the process of mastering CSS grid layout design. If you are curious to see my progress so far, check out this Codepen link showcasing my code. Additionally, for a visual representation of the layout, feel free to view the layout image ...

Storing information from a table into LocalStorage

$('.new_customer').click(function () { var table = $("table"); var number = table.find('tr').length; table.append('<tr id="' + number + '"><td><input type="button" class="btn btn-success btn-xs" ...

Retrieving a value from an Ajax response using JQuery

Utilizing Ajax to trigger a PHP script which then sends back an array of data. When implementing the following code: .done(function( response ) { if(response === false || response === 'false') { $('.main-container').css(&ap ...

Effortless database updating in ASP.Net Gridview using jQuery AJAX without any pesky postbacks

On a specific page, users are required to check items off within a gridview without having to go through the process of clicking Edit and Save. After exploring various sources for information, I was able to come up with the following solution. Within the g ...

Step-by-Step Guide: Building a PHP-powered AJAX Notification System for Friend Requests

I want to develop a unique notification system using AJAX and incorporate some cool Web 2.0 features. With my PHP expertise, I aim to notify users in real-time when their friend request is accepted by $username. This will be achieved through an interacti ...

What is the best way to capture user input using an onClick event in JavaScript and then display it on the screen?

I'm in the process of upgrading a table, and while most of it is working fine, there is one function that's giving me trouble. I want this function to return an input with an inline onClick event. The actual return value is displaying correctly, ...

What is the best way to input keys without losing focus?

I am facing an issue with an HTML <input> field that displays autocomplete suggestions while the user is typing. I want to create an automated test using Selenium, where the driver inputs keys and then verifies the contents of the autocomplete dropdo ...

Tips for adjusting the position of an icon when encountering a line break using Javascript or CSS

After some trial and error, I managed to get it working, but only when the page is initially loaded and not in a responsive manner. Below is the JavaScript code I used. if ( $(".alert-box").height() >= 90 ) { $('.img').css(&apos ...

Showing Information in an HTML Table

I am new to the world of PHP programming and constantly searching for solutions to my problems. If anyone has any ideas, please share them - I greatly appreciate any help in solving this issue. Within my database table, I have data structured as follows: ...

Having issues with Django not recognizing multiple identical GET parameter names

A Django form is being used for filtering data via a GET form: from reservations.models import Reservation, ServiceType from django import forms PAYMENT_OPTIONS = ( ('CASH', 'Cash'), ('ROOM', 'Charge to room&apo ...

How to insert an image into a placeholder in an .hbs Ember template file

I'm looking to enhance a .hbs template file in ember by incorporating an image. I am not a developer, but I'm attempting to customize the basic todo list app. <section class='todoapp'> <header id='header'> & ...

Hover shows no response

I'm having trouble with my hover effect. I want an element to only be visible when hovered over, but it's not working as expected. I've considered replacing the i tag with an a, and have also tried using both display: none and display: bloc ...

Guide on validating a dropdown using template-driven forms in Angular 7

Having trouble validating a dropdown select box, possibly due to a CSS issue. Any suggestions on how to fix this validation problem? Check out the demo here: https://stackblitz.com/edit/angular-7-template-driven-form-validation-qxecdm?file=app%2Fapp.compo ...