Implement jQuery confirmation modal in a form submit?

后端 未结 2 1930
梦如初夏
梦如初夏 2021-01-24 05:37

I am using jQuery modal confirmation like this:

$(function() {
    $( \"#dialog-confirm\" ).dialog({
      resizable: false,
      height:190,
      width: 330,
         


        
相关标签:
2条回答
  • 2021-01-24 06:20

    I have created Model popup by own no third party plugin.

    Could you please try given link.

    <input type="button" id="btnShowSimple" value="Simple Dialog" />
    <input type="button" id="btnShowModal" value="Modal Dialog" />
    

    See Demo

    Hope it likes you.

    0 讨论(0)
  • 2021-01-24 06:32

    you need to use the submit event in the form where the submit button is.

    $(function() {
        var submit = false;
        $("#dialog-confirm").dialog({
          resizable: false,
          height:190,
          autoOpen: false,
          width: 330,
          modal: true,
          buttons: {
            "Yes": function() {
              $(this).dialog("close");
              submit = true;
            },
            No: function() {
              $(this).dialog("close");
            }
          }
        });
    
        $('form').submit(function() {
            if (!submit) {
                $("#dialog-confirm").dialog('open');
                return false;
            }
        });
    });
    
    0 讨论(0)
提交回复
热议问题