You are viewing limited content. For full access, please sign in.

Question

Question

Forms - Show modal dialog on submit

asked on December 8, 2014 Show version history

I am working on a project that needs to show a modal dialog when the user clicks submit.  I have the dialog working.  When the user clicks Submit, the dialog is shown and the form is not submitted.  When the user clicks OK on the dialog, I need the form to be submitted.  This is the part I'm having trouble with.  When the dialog is closed (click yes or no), the Submit button no longer works.  Here is the code I'm using:

    $(document).ready(function () {

        $('#form1').submit(function (evt) {
            if ($("#q4 input").is(":checked")) {
                alert('submit');
                return true;
            } else {
                alert('test');
                showJQueryDialog();
                return false;
            }
        });

    });

    function showJQueryDialog() {
        $('<div id="#pmtDlg"></div>').dialog({
            resizable: false,
            dialogClass: "no-close",
            closeOnEscape: false,
            modal: true,
            buttons: {
                "Yes": function () {
                    $("#q4 input").attr('checked', true);
                    $(this).dialog("close");
                    $('#form1').submit();
                },
                "No": function () {
                    $(this).dialog("close");
                }
            }
        }).html('Would you like to continue?');
    }

Any pointers on how to get this to work will be greatly appreciated.

This is in Forms 9.1.1.1517

Thank you

0 0

Replies

replied on December 10, 2014

After looking through everything more, I found a section of code inside of Forms (js\form\forms.js) that is preventing the form from being submitted.  On line 830, the private variable "submitting" is set to false.  Inside of the submit event handler (line 833), this value is set to true.  Changing the value back to false will allow the form to be submitted.  Is there any way of accessing this value outside of the forms.js file?  

 

I need to be able to have all validation logic run to ensure the form can be submitted once the dialog is closed.  Hooking into the form submit handler seems to be the most reliable way of doing this.  Is there any other way of getting the "submitting" variable set back to false to be able to submit the form or being sure the form is completely valid from another button?

1 0
replied on December 8, 2014

Looks like maybe you just forgot a "#" in your selector in the showJQueryDialog function. ("#form1").submit()

0 0
replied on December 8, 2014

Sorry, that was a type-o when I was cleaning up the code to copy into the post.  I have updated the code in my original post to reflect this.

0 0
replied on December 8, 2014 Show version history

I've had trouble trying to modify the default "submit" behavior before. It looks like you may have some kind of infinite loop where you are triggering a submit event, handling it, and then triggering another submit event within your handler.

My usual workaround is to hide the actual submit button, create a new button on my own that looks the same, and then handle the event for this second button however I like, triggering a press of the original submit button using javascript when appropriate.

To make a button that looks like the submit button, just use a Custom HTML item:

<input id="my_Submit" type="button" class="action-btn" value="Submit">

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.