Rectangle 27 9

In order not to close the modal window, that is, not to refresh the whole page, you need to submit the form values to your php script through ajax call.

$(function() {

    $('#your_form_id').on('submit', function(event) {

        event.preventDefault();

        $.ajax({
            url: "your_php_script.php",
            type: "POST",
            data: {"formFieldName" : formFieldValue}, // here build JSON object with your form data
            dataType: "json",
            contentType: "application/json"
        }).done(function(msg) {
            // this is returned value from your PHP script
            //your PHP script needs to send back JSON headers + JSON object, not new HTML document!
            // update your "message" element in the modal
            $("#message_element_id").text(msg);
        });
    });
};

jquery - How to get Twitter Bootstrap modals to stay open on form subm...

jquery twitter-bootstrap modal-dialog form-submit
Rectangle 27 0

You need to make sure that the inputs and the buttons belong to one form element. This may be hard to achieve with your current markup.

Alternatively, you could submit the form with JavaScript, but the first method is much better, as you get a lot of functionality for free.

if I moved f.submit out of the partial and onto the modal...how would that look? I tried that but couldn't get it working

ruby on rails - How to get the save button in bootstrap modals to subm...

ruby-on-rails forms twitter-bootstrap
Rectangle 27 0

In order not to close the modal window, that is, not to refresh the whole page, you need to submit the form values to your php script through ajax call.

$(function() {

    $('#your_form_id').on('submit', function(event) {

        event.preventDefault();

        $.ajax({
            url: "your_php_script.php",
            type: "POST",
            data: {"formFieldName" : formFieldValue}, // here build JSON object with your form data
            dataType: "json",
            contentType: "application/json"
        }).done(function(msg) {
            // this is returned value from your PHP script
            //your PHP script needs to send back JSON headers + JSON object, not new HTML document!
            // update your "message" element in the modal
            $("#message_element_id").text(msg);
        });
    });
};

jquery - How to get Twitter Bootstrap modals to stay open on form subm...

jquery twitter-bootstrap modal-dialog form-submit
Rectangle 27 0

It seems that you're using the old version of the plugin. From v0.5.0, the plugin removes submitHandler option, according to the Upgrading to v0.5.0 guide. Use the success.form.bv event handler instead.

You might try the following code:

$('#editForm')
    .bootstrapValidator(options)
    .on('success.form.bv', function(e) {
        e.preventDefault(); // Prevent the form from submitting 
        alert('I am going to do other things');

        // ... Do whatever you want

        // If you want to submit the form, use the defaultSubmit() method
        // http://bootstrapvalidator.com/api/#default-submit
        $('#editForm').bootstrapValidator('defaultSubmit');
    });

Thank you, this is clear now. All working as expected.

bootstrap validator : can't get the form to submit (validation ok) - S...

twitter-bootstrap validation modal-dialog