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.
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='layui-this'>tab名称</li>"); $("#layui-tab-content").append(data); layui.use('element', function() { var element = layui.element; element.init(); }); } })
Rendering is mainly in the following element.init(); this sentence
layui.use('element', 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('form', 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!