layui如何提交post


本文摘自PHP中文网,作者尚,侵删。

layui提交post:

table.js

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

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

//表格属性:page,elem,url,cols

//列属性:type,field,title

table.render({

        //1 开启分页

        page: true,

        //2 指定渲染的table容器

        elem: '#articleList',

        //3 异步访问的路径

        url: '../../user',

        //4 集合属性

        cols: [[

            {type: 'checkbox'},

            //4.1   普通属性

            {field: 'username', title: '用户名称',width:'11%'},

            //4.2   单选框属性

            {field: 'sex',      title: '性别',    width:'11%'},

            //4.3   复选框属性

            {field: 'status',   title: '状态',    templet: '#status',width:'11%'},

            //4.4   日期属性

            {field: 'updated',  title: '最近修改时间',width:'14%',

                //日期格式转化

                templet: function createTime(d){

                            return new Date(parseInt(d.updated)).toLocaleString()

                 }

            }, 

        ]]

         

        //4.2   数字条件判断

        ,done:function(res,curr,count){

            $("[data-field='sex']").children().each(function(){

                //若选取元素为1

                if($(this).text() == '1'){

                      

                    $(this).text('男');

                //若选取元素为0

                }else if($(this).text() == '0'){

                     

                    $(this).text('女');

                }

            });

        }

    });

 

    //4.4   调用的日期格式转化器

     Date.prototype.toLocaleString = function() {

        var y = this.getFullYear();

        var m = this.getMonth()+1;

        m = m<10?'0'+m:m;

        var d = this.getDate();

        d = d<10?("0"+d):d;

        var h = this.getHours();

        h = h<10?("0"+h):h;

        var M = this.getMinutes();

        M = M<10?("0"+M):M;

        var S=this.getSeconds();

        S=S<10?("0"+S):S;

        return y+"-"+m+"-"+d;

        /*+" "+h+":"+M+":"+S*/

    };

post.js

阅读剩余部分

相关阅读 >>

layui怎么固定表格的表头

layui列表怎么取input框的值

layui怎么设置checkbox勾选

layui如何获取复选框的值以及如何为复选框赋值

layui的table如何做批量删除

layui前端框架弹出form表单以及提交的方法

layui分页怎么用

layui.laypage怎么用

如何解决layui时间控件闪退问题

layui兼容ie浏览器吗

更多相关阅读请进入《layui》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...