首页 > 其他 > 详细

在layui下对元素进行事件绑定的实例

时间:2019-09-06 14:16:08      阅读:166      评论:0      收藏:0      [点我收藏+]

要注意的是记得要先引用element操作模块 ,否则是无法绑定的

格式:

$(document).on(事件,标识,function(){});

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
layui.use([‘jquery‘, ‘form‘, ‘table‘, ‘element‘], function() {
 var form = layui.form;
 var table = layui.table;
 var element = layui.element;
 var $ = layui.$;
 
 
 // form.render();
 table.render({
  elem: ‘#tableList‘,
  // height: 315,
  url: "{{route(‘admin.data‘)}}",
  page: true, //开启分页
  cols: [
   [ //表头
    { field: ‘id‘, title: ‘ID‘, sort: true, fixed: ‘left‘ },
    { field: ‘name‘, title: ‘用户名‘ },
    { field: ‘role‘, title: ‘角色‘, sort: true },
    {
     field: ‘status‘,
     title: ‘状态‘,
     templet: function(d) {
      return d.status == 0 ? ‘禁止‘ : ‘启用‘
     }
    },
    { field: ‘created_at‘, title: ‘创建时间‘ },
    {
     title: ‘操作‘,
     // minWidth: 200,
     templet: function(d) {
      return ‘<button class="layui-btn layui-btn-xs " lay-filter="editF" id="edit" data-id="‘ + d.id + ‘">编辑</button>‘
     }
    }
   ]
  ]
 });
 //绑定事件
 $(document).on(‘click‘, ‘#edit‘, function(data) {
  var id = $(this).attr(‘data-id‘);
 
 });
 });

在layui下对元素进行事件绑定的实例

原文:https://www.cnblogs.com/weilxiaolat/p/11474253.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!