Question

I have a form inside of a confirm bootbox and I need that the ok button make the submit of this form catch the return of this.

Here is the code that I am using for bootbox

$.get(ruta,
        function(response) {
            bootbox.confirm(response, function(result){
                if(result){

                }
            });
});

and here is my form:

<form class="form-horizontal" id="form" method="POST" action="{{ path ('nueva_pregunta_ajax')}}" {{ form_enctype(form) }} novalidate >

I am using twig like template motor and symfony2 like framework

Was it helpful?

Solution

You should use a dialog for that:

//define your post target
var url = '/example/post';
$.get(ruta,function(response) {
    bootbox.dialog({
        title:'Your fancy title',
        message:response,
        buttons:{
            cancel:{
                label: "Cancel",
               className: "btn-default",
            },
            submit:{
                label: "Submit",
                className: "btn-primary",
                callback: function() {
                    //post the data
                    $.post(url, $('#form').serialize(), function(data){
                        //do something
                    });
                }
            }
        }    
    });
});

Something like that should work

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top