I have a page with a jqueryui dialog box that I want to pass a function name to be run when the dialog box button is clicked. I would like to pass in this function name as a parameter to the calling function. In the mydialog function example I am trying to use the parameter funcName as the function name in the confirm button
So far, I have not been successful in my quest. Any help would be appreciated. myDialog = function(dTitle, funcName) { var $dlog = $("#dialog"); var myFunc = funcName + '()';
if($dlog.length != 0) {
$($dlog).remove();
}
$("body").append("<div id='dialog'></div>");
$("#dialog").dialog({
autoOpen: false,
modal: true,
title: dTitle,
buttons : {
"Confirm" : function() {
myFunc;
$(this).dialog("close");
},
"Cancel" : function() {
$(this).dialog("close");
}
}
});
$("#dialog").dialog("open");
}
$("#function3").click(function() {
runMe = myDialog('Function 3','woot');
})
$("#function4").click(function() {
runMe = myDialog('Function 4','woot');
});
woot = function(){
alert('wooty');
}