jquery - Javascript Alertify wait for confirmation then go to another page -


i new alertify.js . trying is, when user cicks on link, browser should show confirmation box. if user clicks of go next page. if user clicks cancel stay on same page. possible using alertify.js. here html code.

<a href="index.php" class="alert">logout</a> 

here javascript code.

$(".alert").on('click', function(){     alertify.confirm("are sure?", function (e) {         if (e) {             return true;         } else {             return false;         }     }); }); 

but problem whenever click on link, go index.php page before clicking on confirm. please me, stuck days. in advance.

the problem is impossible make code wait. need cancel original click , call code navigate new page.

$(".alert").on('click', function(e){     e.preventdefault();     var href = this.href;     alertify.confirm("are sure?", function (e) {         if (e) {             window.location.href = href;         }     }); }); 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -