I have generic function i need to use in different places. The issue is some places i need to pass function without parameters and some places with parameters to call back function. How can i handle in both the scenarios.
function deletePrompt(message, callback){
$("#deleteModelWindow").modal({
containerCss: {
width: 320,
height: 180,
overflow: 'hidden'},
onShow: function(dialog){ dialog.wrap.css('overflow','hidden'); }
});
document.getElementById("spanid").innerHTML = message;
$("#deleteModelWindow").on('click', "#deleteConfirm", function(){
if (callback !== undefined) {
callback();
} else {
callback(parameter1,parameter2);
}
$.modal.close();
});
$("#deleteModelWindow").on('click', "#cancel", function(){
$.modal.close();
});
}
calling From:
<input id="deleteInvitationBtn" class="buOrange large" type="button" name="submit" value="Delete Invitation" onClick="deletePrompt('Are you sure you want to delete the invitation?', deleteInvitation('${invitation.invitationId}','${invitation.clientActivationCode}'))">
Here, In onclick before it redirects to deletePrompt() it is directly redirecting to the deleteInvitation().
Can anyone explain why this is happening?