Closed Janskiproducer closed 6 years ago
I'm assuming that when you say "call that function from a href tag" you mean, an anchor tag like this:
<a href="#" onclick="kjorpo()">Link</a>
The problem is that clicking on the link triggers a popstate
event - technically, the page is navigating to #
. Vex detects this and by default closes all dialogs.
I would recommend using another element, like a button
, and your code will work fine.
You could also set the option vex.defaultOptions.closeAllOnPopState
to false
to disable that behavior... Closing to clean up!
I am using Vuejs and ran into the same with
<a href="#" v-on:click="confirmDelete(id)"></a>
I cannot prevent the return, but @bbatliner suggestion solved the problem:
vex.defaultOptions.closeAllOnPopState = false;
Thanks.
When trying to make Vex appear on the page, I first tested the initialization as a part of the jQuery document ready section. When the page loads, the dialog loads OK.
I then moved the opening of an alert out into it's own function, and tried to call that function from a href tag. The dialog loads, along with the overlay, but as soon as it's loaded it disappears again instantly.
This is the function I call from the href: function kjorpo(){ vex.dialog.alert({ message: 'This is a test', overlayClosesOnClick: false, showCloseButton: true }); }
Tested in Chrome v. 56