Phil
Phil

Reputation: 2246

How to submit form loaded into BootstrapDialog Modal

I loaded my edit page into a modal dialog using BootstrapDialog https://github.com/nakupanda/bootstrap3-dialog but how do I get the submit button from the BootstrapDialog to submit the form?

Here is a fiddle of the problem. http://jsfiddle.net/philphil/ru1t1nc6/15/

Edit Page

<form id="createEventForm" action="http://10.10.15.30:8000/attendee/edit" style="display:none" method="POST">
    <label for="first_name">First_name:</label>
    <input name="first_name" value="Chris" id="first_name" type="text" />
    <label for="last_name">Last_name:</label>
    <input name="last_name" value="Griffin" id="last_name" type="text" />
    <input type="submit" />
</form>

JQuery

 $(document).ready(function () {

    var form = $('#createEventForm').html();
    BootstrapDialog.show({
        title: 'Title',
        message: form,
        buttons: [{
            label: 'Update'
        }]
    });

});

Upvotes: 0

Views: 3110

Answers (1)

Sam Battat
Sam Battat

Reputation: 5745

How about adding an action to your button:

http://jsfiddle.net/ru1t1nc6/17/

    BootstrapDialog.show({
        title: 'Title',
        message: form,
        buttons: [{
            label: 'Update',
            action: function(dialog) {
                // submit the form
                $('form').submit()
            }
        }]
    });

Upvotes: 1

Related Questions