Home >Web Front-end >Layui Tutorial >Introduction to the problem of layui time control crashing

Introduction to the problem of layui time control crashing

尚
Original
2019-11-30 13:37:412920browse

Introduction to the problem of layui time control crashing

When the project went online, it was discovered that the time control crashed on the sub-page of the backend management system layui, and the time could not be selected at all.

The reason is: if multiple nodes are found on the page, only the first node can be used normally and the subsequent nodes will crash. It can be understood that currently laydate does not support rendering multiple nodes at one time. It's not a matter of duplicate instances, because the instances I create for each page are different and it still crashes. In the background management system, this kind of parent-child page does have multiple pages that use time controls, thereby rendering multiple nodes.

Solution:

The default configuration in the laydate file, trigger: 'focus' //The focus of the event of the callout control is changed to click.

The test deployment is effective online.

layui.use('laydate', function(){
    var laydate = layui.laydate;

    //日期时间选择器
    laydate.render({
        elem: '#startTime'
        ,type: 'datetime'
        ,trigger: 'click'//呼出事件改成click
        //,format: 'yyyy-MM-dd HH:mm:ss' //可任意组合
    });
    //日期时间选择器
    laydate.render({
        elem: '#endTime'
        ,type: 'datetime'
        ,trigger: 'click'//呼出事件改成click
        // ,format: 'yyyy-MM-dd HH:mm:ss' //可任意组合
    });
});

For more layui knowledge, please pay attention to the layui usage tutorial column.

The above is the detailed content of Introduction to the problem of layui time control crashing. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn