layer弹出层自定义提交取消按钮的例子

所属分类: 网络编程 / JavaScript 阅读数: 1806
收藏 0 赞 0 分享

首先从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名进行获取数据
    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函数实现

/**
 * 关闭此对话框
 */
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");
};

途中有一个错误就是把函数名称成为close()了,这个和关键字重复了,导致没有效果出现,关闭不了。

以上这篇layer弹出层自定义提交取消按钮的例子就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

更多精彩内容其他人还在看

深入解析Vue 组件命名那些事

本篇文章主要介绍了深入解析Vue 组件命名那些事,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
收藏 0 赞 0 分享

Vue学习笔记进阶篇之vue-cli安装及介绍

这篇文章主要介绍了Vue学习笔记进阶篇之vue-cli安装及介绍,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

jquery版轮播图效果和extend扩展

这篇文章主要为大家详细介绍了jquery版轮播图效果,以及extend扩展的相关资料,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

jQuery Validate格式验证功能实例代码(包括重名验证)

本文通过实例代码给大家介绍了jQuery Validate格式验证功能,代码中包括重名验证的方法,需要的的朋友参考下吧
收藏 0 赞 0 分享

Angular.js中angular-ui-router的简单实践

本篇文章主要介绍了Angular.js中angular-ui-router的简单实践,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

JavaScript实现二维坐标点排序效果

这篇文章主要为大家详细介绍了JavaScript实现二维坐标点排序效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

深入理解vue2.0路由如何配置问题

本篇文章主要介绍了vue2.0路由配置问题,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
收藏 0 赞 0 分享

基于bootstrap实现多个下拉框同时搜索功能

这篇文章主要为大家详细介绍了基于bootstrap实现多个下拉框同时搜索功能,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

JavaScript 值类型和引用类型的初次研究(推荐)

这篇文章主要介绍了JavaScript 值类型和引用类型的初次研究,需要的朋友可以参考下
收藏 0 赞 0 分享

利用jQuery异步上传文件的插件用法详解

这篇文章主要介绍了利用jQuery异步上传文件的插件用法详解,需要的朋友可以参考下
收藏 0 赞 0 分享
查看更多