http://www.ericmmartin.com/projects/simplemodal/
From the documentation:
onClose: Useful for adding effects to the closing of the modal dialog elements. After you’ve applied effects, etc., you’ll need to call $.modal.close(); so SimpleModal can re-insert the data correctly and clean up the dialog elements.
You need to include a call to $.modal.close()
in your onClose()
handler, e.g.
onClose: function(){
console.log(flag);
if(flag) $.modal.close();
}
ps. As for the flag
variable, it's getting set up exactly as you expected it to. It's not the problem.