2017-04-21 85 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