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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -