opHASnoNAME opHASnoNAME - 2 months ago 9
jQuery Question

Translate "Buttons" in JQuery UI Dialogs

I have 2 Javascript Files with Translations, wich will be included depending on users language. This works fine for most cases. But not for the Buttons object inside an JQuery UI Dialog. Any ideas how to solve this?

if (data.status == 'success') {
options = {
buttons: {
CLOSE: function() {
$(this).dialog('close');
}
}
};


CLOSE must be translated..

Answer

Create the buttons object like this:

var myButtons = {};
myButtons[CLOSE] = function() { $(this).dialog('close'); };

if (data.status == 'success') {
  options = {
    buttons: myButtons
  };
}

Edit: Updated to use the CLOSE variable.