Layui Write Backstage Form Thinking and Assignment Learn

Layui.form module usage summary.

Based on LAYUI to do value

1. Initial one is used to assign a population, one assignment In order to assign a value according to the data, one is to empty data

Function initContorl (data) {// transmit data assignment is an array that does not pass data assignment is empty IF ( Data) {Form.Val (“Control”, DATA)} else {form.val (“control”, {“name1”: “,” name2 “:”, “name3”: “})}

* Layui in form.val (); method Form.Val (“Control” in the
 tab in the  tab, Name1, Name2, name2 is the name attribute value of INPUT, I am generally set to the same  
* assignment


Name Val



Name Val


Name Val

5 Switch

Name Val (True / Fasle)

6 more choices to make people Layui To set different names and set the corresponding Name to True and need Name: Vule’s JSON format.

Subject to pass to the backend

name value assignment intdata [ “subject [” + el.st_grade + “]”] = true; intdata passed initContorl (data) data argument

Therefore, multiple choice assignments: name [vlue] val (true. / fasle);

* empty empty is no transmission data initContorl

1-5 6 to set their own $ ( “input: checkbox”) attr ( “checked”, false);. form after use to update the state form.render ( ‘checkbox’);

form data obtaining two;

layui table values ​​is acquired at the time of listening form submission Submit form button structures

submitted to the

method listener

form.on ( ‘submit (filter values)’, function (data) {data. field // is the value of the acquired form; return false; // preventing form submission data processing using jaxa})

comment Grab the couch

Please log in to comment