Create Button Array For Jquery Dialog
Is it possible to create a button array then append it to a jQuery dialog? Something along these lines. Forgive my errorful code within the for loop, just not sure how to do this
Solution 1:
Something like this should work :
functionsetAutoDialog(){
var testArray = ["T1", "T2"];
var testFunction = function () {
alert("worked");
}
var myButtons = {};
for(var i = 0; i < testArray.length; i++){
myButtons[testArray[i]] = testFunction;
}
$('#autoDialog').dialog({
autoOpen: false,
width: 'auto',
buttons : myButtons
});
}
"For instance on click instead of alert(worked) I want to get alert(buttonClicked.val())?" It would be something like :
functionsetAutoDialog(){
var testArray = ["T1", "T2"];
var myButtons = {};
for(var i = 0; i < testArray.length; i++){
var testFunction = function () {
alert(testArray[i]);
}
myButtons[testArray[i]] = testFunction;
}
$('#autoDialog').dialog({
autoOpen: false,
width: 'auto',
buttons : myButtons
});
}
Post a Comment for "Create Button Array For Jquery Dialog"