2013-08-01 34 views
0

我有一个表单,我想添加一个确认对话框以提交。我正在使用this库,它在大多数情况下工作得很好,但是当我在窗体上使用它时,似乎无法使窗体等待来自此的响应。我敢肯定它是与我如何调用该函数确认,但我不知道是什么原因jquery使表单提交等待函数调用的响应

$('#process_quote').submit(function(){ 
      $.confirm({ 
       text: "Would you like to enter shipping information for this quote?", 
       confirm: function(button) { 
        $('input[name=enter_shipping]').val(1); 
       }, 
       cancelButton: "No", 
       cancel: function(button) { 
        $('input[name=enter_shipping]').val(0); 
       } 

      }); 

      return true; 
     }); 

回答

1

将您的确认按钮单击处理程序。然后当你有你的用户确认提交提交请求。

$('button.trigger').on("click", function(){ 
     $.confirm({ 
      text: "Would you like to enter shipping information for this quote?", 
      confirm: function(button) { 
       $('input[name=enter_shipping]').val(1); 
       $("#process_quote").submit(); 
      }, 
      cancelButton: "No", 
      cancel: function(button) { 
       $('input[name=enter_shipping]').val(0); 
      } 

     }); 
    }); 
+0

还有什么更多的吗?我给了我的按钮一个submit_button的id,由于某种原因,它甚至没有触发对话?它声明theat submit_button没有方法点击 – ed209

+0

不是?这里的工作示例http://jsfiddle.net/jasenhk/BPwUn/。 – Jasen

+0

我用Bootstrap资源更新了jsfiddle。 – Jasen