I have this main function which takes 1 string and 2 callback functions as the argument. Below is the code.
function confirmYesNo(confirmMessage, confirmCallback, cancelCallback) {
$("#yes-button").click(function () {
confirmCallback(); //How do I pass confirmCallback arguments
});
...
}
Here is how the function is invoked
function confirmYesNoTest() {
var confirmContent = "Some Message"
var id = "1";
confirmYesNo(confirmContent,
function (id) { alert(id); }, //alerts undefined
function () { alert("Cancel Clicked"); });
}
The problem is that the id variable above (which is set to 1) comes out as "undefined" when the confirmCallback executes. Seems something related to scope, but I am not able to get this working.