I'm using a bootbox to log in my users and would like to keep it open if there are errors. From this link it looks like all I have to do is use return false. However, my bootbox is still closing; my guess is that it's because I'm sending an ajax request to do the form validation.
Is there anyway to keep the bootbox open as I check whether username/password are valid serverside? And, one solution that seems to work is to just create a function to open the bootobx, and just re-open it on failure, but a "cleaner" solution would be appreciated.
bootbox.dialog({
message: message,
title: "Log In",
buttons: {
success: {
label: "Submit",
className: "btn-success",
callback: function() {
var username = $('.bootbox-body input[name="username"]').val();
var password = $('.bootbox-body input[name="password"]').val();
$.post('ajax/sign_in.php', {
username: username,
password: password
}, function() {}, 'json').done(function(o) {
if (o.success) {
//send them to a new page
}
if (o.error) {
$('#login_error').html(o.error);
//oops! the bootbox has closed
}
});
}
}
}
});