using jquery ui modal dialog to submit a form

后端 未结 1 996
别跟我提以往
别跟我提以往 2021-01-14 06:19

I am having difficulty using JQuery UI Modal Dialog when submitting a form. The intent is you hit the submit button, the modal pop ups and depending on your selection from t

相关标签:
1条回答
  • 2021-01-14 07:01

    Use a button labeled "Submit" to open the dialog:

    <div id="dialog" title="Basic dialog">
        <p>Please double check to be sure all data is entered correctly.</p>
    </div>
    <div class="buttons">
        <asp:Button ID="btnSave" Text="Save for later" runat="server" OnClick="btnSubmit_Click" ValidationGroup="GroupSave" />
        <input type="button" id="preSubmit" value="Submit" />
        <asp:Button ID="btnSubmit" class="ui-helper-hidden" Text="Submit" runat="server" OnClick="btnSubmit_Click" />
    </div>
    

    Use the Submit button in the dialog to trigger the click event for your <asp:Button>.

    function submitForm() {
        $('input#<%=btnSubmit.ClientID %>').click();
    }
    function checkSubmit() {
        $("#dialog").dialog({
            "modal": true,
            "buttons": {
                "Submit": function() {
                    submitForm();
                },
                "Go Back": function() {
                    $(this).dialog("close");
                }
            }
        });
    }
    $(document).ready(function() {
        $('button#preSubmit').click(function(e) {
            checkSubmit();
            e.preventDefault();
            return false;
        });
        $('button#saveForLater').click(function(e) {
            $("#dialog").dialog('close');
            e.preventDefault();
            return false;
        });
    });​
    
    0 讨论(0)
提交回复
热议问题