I have two JavaScript files with translations, which will be included depending on the 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.
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.
There are two ways to specify buttons in a dialog (since 1.8.5). Only one of them is useful for internationalization. Define your options like this:
if (data.status == 'success') {
options = {
buttons: [{
text: CLOSE,
click: function() {
$(this).dialog('close');
}
}]
}
}
@dioslaska's solution works as well, but I think this way is prettier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With