欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

layer關(guān)閉彈出窗口觸發(fā)表單提交問題的處理方法

 更新時(shí)間:2019年09月25日 09:05:57   作者:蔚藍(lán)色天空sky  
今天小編就為大家分享一篇layer關(guān)閉彈出窗口觸發(fā)表單提交問題的處理方法,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧

1、前言

表單的代碼:

<form>

 此處理代碼略...

 <div id="footer">
  <button class="btn btn-success" name="save" type="submit" title="保存">保存</button>
  <button class="btn btn-success" id="_closed" οnclick="closeCurrForm()">關(guān)閉</button>
 </div>
</form>

closeCurrForm函數(shù):

//關(guān)閉當(dāng)前窗口
function closeCurrForm(){
  //獲取窗口索引
  var index = parent.layer.getFrameIndex(window.name); 
  parent.layer.close(index);
}

2、問題及原因和解決方法

問題:上面的代碼在點(diǎn)關(guān)閉按鈕后,會(huì)確發(fā)提交表單請求,會(huì)將表單的信息進(jìn)行保存操作。但關(guān)閉按鈕是不需求執(zhí)行保存操作的。

原因:關(guān)閉按鈕沒有標(biāo)識(shí)type屬性,系統(tǒng)會(huì)默認(rèn)其type屬性為submit,所以點(diǎn)擊它就會(huì)觸發(fā)保存操作。

解決方法:為關(guān)閉安鈕添加type屬性,值為button。type=”button”

3、具體代碼如:

此處理代碼略...

 <div id="footer">
  <button class="btn btn-success" name="save" type="submit" title="保存">保存</button>
  <button class="btn btn-success" id="closeBtn" type="button" >關(guān)閉</button>
 </div>
</form>

觸發(fā)事件代碼:

$(document).ready(function () {
  //關(guān)閉當(dāng)前窗口
  $("#closeBtn").click(function(){
    //獲取窗口索引
    var index = parent.layer.getFrameIndex(window.name); 
    parent.layer.close(index);
  });
)};

這樣處理后,點(diǎn)關(guān)閉按鈕后就直接關(guān)閉窗口,不再執(zhí)行保存操作。

以上這篇layer關(guān)閉彈出窗口觸發(fā)表單提交問題的處理方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論