Home >Web Front-end >Layui Tutorial >How to re-render layui

How to re-render layui

藏色散人
藏色散人Original
2020-11-09 11:39:019137browse

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();
                    });
                }
            })

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

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

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();
    });

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!

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
Previous article:How to add icons in layuiNext article:How to add icons in layui