I have looked for a while, but I can\'t find a solution for this. I want the following:
I know this is a late answer, but it might be useful. Here's a proper and clean way to get this done, as @karima's mentioned above. You can actually fire two functions at once; trigger and dismiss the modal.
trigger
dismiss
HTML Markup;
... ...
Demo