How to re-render layui

藏色散人
Release: 2020-11-17 18:17:25
Original
9103 people have browsed it

Layui re-rendering method: first load the html page through layUI ajax; then insert the html into the specified position and re-call "element.init();" to render.

How to re-render layui

Recommended: "layui tutorial"

layUI ajax re-renders after loading the html page

Related questions are the same as:

1. When layUI uses jquery.load to load the interface, how to let layui render the page?

2. layUI ajax loads the html page and then renders it again.

layUI ajax loads the html page and then renders it. The key is to insert the html into the specified position and re-call element.init(); rendering

$.ajax({
                url : url,
                type : 'GET',
                success : function(data) {
                    $("#layui-tab-title").append("<li class=&#39;layui-this&#39;>tab名称</li>");
                    $("#layui-tab-content").append(data);
                    layui.use(&#39;element&#39;, function() {
                        var element = layui.element;
                        element.init();
                    });
                }
            })
Copy after login

Rendering is mainly in the following element.init(); this sentence

layui.use(&#39;element&#39;, function() {
        var element = layui.element;
        element.init();
    });
Copy after login

Similarly, if the radio in the form is not rendered, adding the following code to the loading page can also solve the problem:

layui.use(&#39;form&#39;, function() {
        var form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功
        form.render();
    });
Copy after login

The above is the detailed content of How to re-render layui. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template