kamranahmedse / jquery-toast-plugin

Highly customizable jquery plugin to show toast messages
http://kamranahmed.info/toast
1.51k stars 506 forks source link

toast shows for very less time while using in submit #17

Closed wasifnazirmalik closed 8 years ago

wasifnazirmalik commented 8 years ago

Hello I'm a new coder i am using this plugin for form submission whenever the form is submitted the toast appears for a small amount of time and then the page reloads automatically after submit please help following is my code: $(document).ready(function(e) {

$("#form").submit(function (e) {

$.toast({
text: "User Registered",
heading: 'Admission Successful',
icon: 'success',
showHideTransition: 'fade',
allowToastClose: true,
hideAfter: false, 
stack: false, 
position: 'mid-center', 
});

});

});

thanks in advance

kamranahmedse commented 8 years ago

You can use a mix of toast events and timer to handle that i.e. replace the toast call to this for example

e.preventDefault();
// Do your ajax call or whatever
// to register the user

// Show the toast for 5 seconds and then reload/redirect
$.toast({
    text: "User Registered",
    heading: 'Admission Successful',
    icon: 'success',
    showHideTransition: 'fade',
    allowToastClose: true,
    hideAfter: 5000,   // in milli seconds
    beforeHide: function () {
          // do the redirect/reload
    };
})