I have a wireEvents function that bind javascript with form events. For example,
$(document).on('click', '#cancelEdit', cancelEdit);
I do it this way because the #cancelEdit button is added later from a jsRender template. It works fine. When the button is clicked, cancelEdit function is called.
var cancelEdit = function (event) {
event.preventDefault();
...
};
But now I want to add a callback function onto cancelEdit like this;
var cancelEdit = function (event, callback) {
event.preventDefault();
...
};
How should I update the event wiring statement? Like this?
$(document).on('click', '#cancelEdit', cancelEdit('click', cancelEditCallBack));
I cannot make it work. Please help.
Thank you.
You can pass additional arguments to a callback by using the data parameter.