URL: blog.csdn.net/xuexiiphone…

Recently I’ve been using Layui, a relatively programmer friendly front-end framework, with many of the effects initially encapsulated.

In the use of the most encountered problems is the problem of reference, all kinds of templates can not be used, although all one baidu solution.

The problem is that layui-form cannot render.

What I’m hoping for is

But the program works

Problem analysis:

Because of this form, I used LaytPL to insert it dynamically, so the radio effect in the form is not rendered, you can see it in debug mode

A normal radio render would include an I tag and a SPAN tag

Our render result, on the other hand, only has an input tag

So there is no data for this location.

Solution:

Since the framework is relatively new, most of the content can only be obtained through the forum on the official website, so I searched for a long time, and finally SAW a sentence in the official document

In some cases, some of your form elements may be inserted dynamically. In this case, the automatic rendering of the Form module will be disabled. Although we don't have a bidirectional binding mechanism (because we call it a classic modular framework, bahahahaha...) But that's fine, you just need to call form.render(type); Method can. Type is the type type of the form, which is optional. By default, all types of forms are updated once. The types that can be partially refreshed are as follows:Copy the code

So I added a sentence at the end of the template insertion code

form.render(); // Update allCopy the code

Ok, problem solved !!!!!