layer彈出層自定義提交取消按鈕的例子
首先從js開始
/**
* 檢查是否選中
*/
Sendandre.check = function () {
var selected = $('#' + this.id).bootstrapTable('getSelections');
if (selected.length === 0) {
Feng.info("請先選中表格中的某一記錄!");
return false;
} else {
Sendandre.seItem = selected[0];
console.log(Sendandre.seItem);
return true;
}
};
/**
* 點擊修改按鈕時
*/
Sendandre.openChangestan = function () {
if (this.check()) {
this.layerIndex = layer.open({
type: 2,
title: '修改收派標準',
area: ['800px', '400px'], //寬高
fix: false, //不固定
maxmin: true,
content: Feng.ctxPath + '/sendandreceive/stander_edit?sendid=' + this.seItem.sendid,
success: function (layero, index) { //成功獲得加載changefile.html時
//// console.log(obj.data.editAble);
var body = layer.getChildFrame('body', index);
//console.log(rowselect[0].filename);
body.find(".sendname").val(Sendandre.seItem.sendname); //通過class名進行獲取數(shù)據(jù)
body.find(".minwe").val(Sendandre.seItem.minwe);
body.find(".maxwe").val(Sendandre.seItem.maxwe);
}
});
}
};
然后是彈出層加載的界面
@layout("/common/_dialog.html",{plugins:["laydate","sweet-alert","layer"],js:["/assets/modular/system/basic/sendandre/send_edit.js"]}){
<div class="container-fluid">
<form id="sendandreForm">
<div class="row">
<div class="col-6">
<div class="form-group">
<h5>標準名稱 <span class="text-danger">*</span></h5>
<div class="controls">
<input name="sendname" type="text" class="form-control sendname" id="sendname">
</div>
</div>
<div class="form-group">
<h5>最小重量 <span class="text-danger">*</span></h5>
<div class="controls">
<input name="minwe" type="text" class="form-control minwe" id="minwe">
</div>
</div>
<div class="form-group">
<h5>最大重量 </h5>
<div class="controls">
<input name="maxwe" type="text" class="form-control maxwe" id="">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-6">
<div class="text-xs-right">
<button class="btn btn-info normal-button-width" onclick="ensure()">提交</button>
<button class="btn btn-inverse normal-button-width m-l-10" onclick="closehe()">取消</button>
</div>
</div>
</div>
</form>
</div>
@}
然后是js函數(shù)實現(xiàn)
/**
* 關(guān)閉此對話框
*/
closehe = function () {
console.log("close");
// var inde=parent.layer.getFrameIndex(window.name);
var index = parent.layer.getFrameIndex(window.name);
console.log(index);
parent.layer.close(index);
};
ensure = function () {
console.log("daodao");
};
途中有一個錯誤就是把函數(shù)名稱成為close()了,這個和關(guān)鍵字重復了,導致沒有效果出現(xiàn),關(guān)閉不了。
以上這篇layer彈出層自定義提交取消按鈕的例子就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
javascript垃圾收集機制與內(nèi)存泄漏詳細解析
本文是對javascript中的垃圾收集機制與內(nèi)存泄漏進行了詳細的分析介紹,需要的朋友可以過來參考下,希望對大家有所幫助2013-11-11
微信小程序?qū)崿F(xiàn)跳轉(zhuǎn)的幾種方式總結(jié)(推薦)
這篇文章主要介紹了微信小程序跳轉(zhuǎn)方式,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2019-04-04
代碼短小的js div層拖動實現(xiàn)代碼[兼容IE與Firefox]
代碼短小的js div層拖動實現(xiàn)代碼[兼容IE與Firefox],需要的朋友可以參考下.2010-05-05
JavaScript如何將時間戳轉(zhuǎn)化為年月日時分秒格式
這篇文章主要給大家介紹了關(guān)于JavaScript如何將時間戳轉(zhuǎn)化為年月日時分秒格式的相關(guān)資料,在前端的日常工作當中,時間戳的使用也是不少的,有時后端返回給我們的數(shù)據(jù)是一個時間戳,我們需要轉(zhuǎn)換成年月日,時分秒的形式展示在頁面當中,需要的朋友可以參考下2023-11-11
js超時調(diào)用setTimeout和間歇調(diào)用setInterval實例分析
這篇文章主要介紹了js超時調(diào)用setTimeout和間歇調(diào)用setInterval,以實例形式對比分析了setTimeout與setInterval的具體使用技巧,非常具有實用價值,需要的朋友可以參考下2015-01-01

