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!
How do I use Layui's flow module for infinite scrolling?Mar 18, 2025 pm 01:01 PMThe article discusses using Layui's flow module for infinite scrolling, covering setup, best practices, performance optimization, and customization for enhanced user experience.
How do I use Layui's element module to create tabs, accordions, and progress bars?Mar 18, 2025 pm 01:00 PMThe article details how to use Layui's element module to create and customize UI elements like tabs, accordions, and progress bars, highlighting HTML structures, initialization, and common pitfalls to avoid.Character count: 159
How do I customize the appearance and behavior of Layui's carousel module?Mar 18, 2025 pm 12:59 PMThe article discusses customizing Layui's carousel module, focusing on CSS and JavaScript modifications for appearance and behavior, including transition effects, autoplay settings, and adding custom navigation controls.
How do I use Layui's carousel module to create image sliders?Mar 18, 2025 pm 12:58 PMThe article guides on using Layui's carousel module for image sliders, detailing steps for setup, customization options, implementing autoplay and navigation, and performance optimization strategies.
How do I configure Layui's upload module to restrict file types and sizes?Mar 18, 2025 pm 12:57 PMThe article discusses configuring Layui's upload module to restrict file types and sizes using accept, exts, and size properties, and customizing error messages for violations.
How do I use Layui's layer module to create modal windows and dialog boxes?Mar 18, 2025 pm 12:46 PMThe article explains how to use Layui's layer module to create modal windows and dialog boxes, detailing setup, types, customization, and common pitfalls to avoid.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Chinese version
Chinese version, very easy to use

Dreamweaver Mac version
Visual web development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Atom editor mac version download
The most popular open source editor






