JavaScript .Dialog Dynamic button names -
so have similar this
$("#id").html(msg2show).dialog({ //other attributes buttons: { "yes": function() {//code}, "no": function() {//code} } });
i adding other language support site. there way dynamically change "yes" , "no" out duplicate code?
i have tried using following , replacing strings above variable names, seems interpret variable names strings rather value of variable.
var yes = 'si'; var no = 'no';
build buttons object before passing .dialog()
, can use variables keys bracket notation:
var yes = 'si'; var no = 'no'; var buttons = {}; buttons[yes] = function() {}; buttons[no] = function() {}; $("#id").html(msg2show).dialog({ //other attributes buttons: buttons });
Comments
Post a Comment