How to click the button after displaying the dialog box in jquery

32 views Asked by At

Using Zend framework and jquery.

I am trying to display a dialog on button click .The dialog have 2 buttons continue and cancel.I need to continue the execution of button click when the user click on continue.

$this->addElement('Submit', 'returnleg', array
                (
                    'label'     => 'Add Leg',
                    'class'     => 'centre'
                ));

This is the button in the Form. The Form id is bookingview. When I click on the particular button I am using some jquery to load a dialog .


$(document).ready(function () {
    $(function (e) {
        $("#add-leg").dialog({
            autoOpen: false,
            draggable: false,
            resizable: false,
            modal: true,
            buttons: [
                {
                    text : $('.add-leg').attr('data-confirm'),
                    click : function( e) {
                        $("#bookingview .returnleg").trigger('click');
                        $( this ).dialog( "close" );
                    }
                },
                {
                    text : $('.add-leg').attr('data-cancel'),
                    click: function() {
                        $( this ).dialog( "close" );
                    }
                }
            ]
        });
        $("#returnleg").click(function (e) {
            e.preventDefault();
            $("#add-leg").dialog("open");
        });
    });

This code will work when the returnleg is clicked. At first this cancel the default action and displays the dialog box. The issue is that ,I don't know how to continue the action when user click on continue. I tried using

 $("#bookingview .returnleg").trigger('click');

But I am not sure this is the currect way as I don't have an onclick for the button element. How can I contiue the action of the form after displaying the dialog.

1

There are 1 answers

0
hanif zekri On

If I am not in the wrong place, i think using submit() will fix the problem.

$("#bookingview").submit();