2017-04-21 143 views
0

我面临与IE的问题,其中表单提交了很多次,提交按钮的点击次数.. 这里是我流..表单在IE中多次提交取决于没有点击提交按钮

-> User enters the data in the form and upon click of submit button, will validate 
     the from 
    -> if form data is valid, will open a bootstrap confirm request modal to show the data that was 
     entered and will provide another confirm submit button..when users clicks on 
     Confirm Submit button, will submit the form 

一切正常,到目前为止,但是当我们关闭确认reqeust引导模式,并点击再次提交和确认下一个点击现在提交关于模式的按钮,渐渐提交表单的两倍。

所以基本上当我们关闭确认请求模式并重做同一个过程时,一次又一次提交(就是关闭con确定reqeust模式,然后点击init提交按钮),然后最后当我们点击模式上的confrim提交按钮时,然后根据提交按钮的点击次数,表单被提交了很多次数...

** its happening only in IE** 

我的init提交按钮代码:

<div class="form-group actionBtnGrp"> 
     <div class="col-sm-offset-5 col-sm-7"> 
      <button type="reset" class="btn btn-form-action btn-primary-grey resetFormData"> 
       <spring:message code="cancel"></spring:message> 
      </button> 
      <button type="submit" class="btn btn-form-action btn-primary-sub formSubmitBtn" id="saveBtn"> 
       <spring:message code="submit"></spring:message> 
      </button> 
     </div> 
</div> 

我确认模式 - confrim提交按钮

<div class="modal-footer"> 
     <button type="button" id="subForm"class="btn btn-primary-sub">Confirm 
      Request</button> 
     <button type="button" class="btn btn-secondary" 
      data-dismiss="modal">Cancel</button> 
    </div> 

我的jQuery提交代码:

$("#policy-form").on('submit', function(event){ 
    var isvalidate=$('#policy-form').valid(); //calling validation method and doing validation 
    if(isvalidate) { 
     if(!$("#confirm-request").data('bs.modal') || $("#confirm-request").data('bs.modal').isShown != true) { //checking confirm modal is open and opening 
      $("#confirm-submit").modal('show'); 
      $('#subForm').text('Confirm Request') 
       .prop('disabled', false); 
      event.preventDefault ? event.preventDefault() : (event.returnValue = false); 
     } 
    } 
}); 

confrim要求开模,做的东西,atlast将有confrim提交按钮提交请求..

$('#confirm-request').on('show.bs.modal', function (e) { // confirm request bootstrap modal 
..//// doing something else 
    // finally submitting the request upon clicking confirm submit from 

$('#subForm').click(function() { 
     $(this).text('Submitting ...') 
      .prop('disabled', true); 
     $('#policy-form').submit(); // submitting the form.. 
    }); 

如说,在关闭并重新打开引导连连模态的,将提交(当我们点击cofirm提交按钮... IE浏览器缓存点击提交按钮的次数,然后提交很多次数?)

anyhelp真的很感激,自昨天以来一直受此打击..

谢谢..

回答

0

它看起来不像IE问题。这是您的click绑定的问题。您将click处理程序绑定到on回调中的元素。这意味着每次显示模态时都要绑定一个新的处理程序。

$('#confirm-request').on('show.bs.modal', function (e) { // confirm request bootstrap modal 
..//// doing something else 
// finally submitting the request upon clicking confirm submit from 

$('#subForm').click(function() { 
    $(this).text('Submitting ...') 
     .prop('disabled', true); 
    $('#policy-form').submit(); // submitting the form.. 
}); 

使它看起来这

$('#subForm').click(function() { 
    $(this).text('Submitting ...') 
     .prop('disabled', true); 
    $('#policy-form').submit(); // submitting the form.. 
}); 

$('#confirm-request').on('show.bs.modal', function (e) { // confirm request bootstrap modal 
..//// doing something else 
// finally submitting the request upon clicking confirm submit from 
+0

感谢您的答复@ gforce301喜欢...我不是亲中的jQuery/javascript..canü帮助我,我需要在这种情况下做.. !! – marc

+0

但我需要显示确认请求的模态和审查数据后,他将点击确认提交按钮,这是在模态,然后提交从.. – marc

+0

我已经把它放在答案。删除以$('#subForm')开始的部分,单击'并将其放在以$('#confirm-request')开头的部分之上'on' – gforce301