I'm using jQuery bootstrap modal. I would like the caller of the modal to pass a function to it somehow so that when the modal has successfully done it's thing, it can execute the function that the caller passed to it. If the modal is cancelled/dismissed, this function should not be executed.
How can this be done?
My caller code is something like this
var doSomething = function() {
// some code here
}
$('#aBtn').click(function() {
#('#myModal').modal();
// if the modal is dimiseed using cancel button do no nothing.
// The modal submits an ajax form, if it is successful then execute the following function
doSomething();
});