I have variables holding the translated labels for buttons inside a jquery ui dialog.
I cannot fill the button array key with the variable itself, and can\'t find an
I know this is 4 years old, but it is the top result for an issue I have been having. Here was the results of my labor.
Simply call the function in a mouse or keyboard event, reference a function (without parentheses), define the buttons or set blank, set a title, and set the text to be displayed.
function confirmDialogue(fn, value, ok, cancel, title, text){
if (typeof ok == "undefined" || ok == ""){ok = "Ok";}
if (typeof cancel == "undefined" || cancel == ""){cancel = "Cancel";}
var buttonsOpts = {};
buttonsOpts[ok] = function() {fn(value);$( this ).dialog( "destroy" );}
buttonsOpts[cancel] = function() {$( this ).dialog( "destroy" );}
var NewDialog = $('' + text + '
');
NewDialog.dialog({
title: title,
dialogClass: "dialogue",
modal: true,
height: "auto",
width: "auto",
show: true,
hide: true,
close: function(){$(this).dialog('destroy');},
buttons: buttonsOpts
});
return false;
}