javascriptjquerytwitter-bootstraptwitter-bootstrap-3bootstrap-dialog

Bootstrap Dialog - How do I stop it closing automatically


I am using a Ajax to call a MVC controller to submit a form, on a successful call I want to display a dialog box, currently its working the way I want to but the box opens for about a second then closes.

$("#addBtn").click(function () {
    $(".container form").ajaxSubmit({ url: '/umbraco/Surface/Basket/AddNow', type: 'post', success: function () { afterSuccess(); } })
});

function afterSuccess() {
    BootstrapDialog.alert('Test');
}

Why this is happening?


Solution

  • The problem was not in the Java Script, the problem was in the html of the page. I moved the submit button out side of the form.

    This must happen quite a lot! - Hope this helps some else.