How to make Bootbox await user confirmation?

Asked

Viewed 10 times

-1

I’m trying to send a message using the BootBox the moment the user clicks on the button GRAVAR but the message is not waiting for the user’s reply and message disappears, the message is displayed but does not wait for the answer, I have tried with the two alternatives I found right here SO, when clicking on the button I tried this code:

// PEGANDO A URL
var URLString = window.location.href;

$('.js-primary-save').click(function(e) {
    var link = URLString;
    e.preventDefault();   
    bootbox.confirm({
        message: "Você deseja encerrar o processo? Não será possível reverter",
        buttons: {
            confirm: {
                label: 'Yes',
                className: 'btn-primary'
            },
            cancel: {
                label: 'No',
                className: 'btn-default'
            }
        },
        callback: function (result) {
            if (result) {
                location.href = link;
            }                        
        }
    });
});

The message is displayed but does not expect reply, and my form is like this:

inserir a descrição da imagem aqui

and tried to do submit but then the message is not even displayed, I tried that way:

$('#Form6123b7264991e').submit(function() {
    var currentForm = this;
    bootbox.confirm("Are you sure?", function(result) {
        if (result) {
            currentForm.submit();
        }
    });
});

I’ll attach an image of that attempt.

inserir a descrição da imagem aqui

The form is generated dynamically.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.