Based on the JavaScript example below, is there a way to pass a reference to function f
to the promptForProceed
function and have it conditionally executed in promptForProceed
?
Could you also do this if the f
function took some parameters (ie: f(a, b, c) { ... }
)?
function f() {
//Do stuff..
}
function promptForProceed(myFunction) { // <------ PASS FUNCTION AS PARAMETER
$("#div-dialog-proceed").dialog({
modal: true,
buttons: {
"Stay on current page": function () {
$(this).dialog("close");
},
"Continue": function () {
$(this).dialog("close");
myFunction(); // <--------- CALL FUNCTION
}
}
});
}
Update: Think I like the option of using an anonymous function parameter:
promptForProceed(function() { //Do stuff like call f(a,b,c) });