<inputtype= "text"ID= "Campus"class= "Layui-input"onkeyup= "ck (this.value);"placeholder= "Please enter the English house to find">//Input Trigger box<Divclass= "Layui-input-block layui-form"ID= "Cam"Lay-filter= "Cam">This is the container for the campus to be displayed, this page is rendered</Div>//Template data//Because this piece uses the Layui statement and the jfinal statement, you need to put the Layui # with the jfinal # to make Layui as a normal string output<Scripttype= "text/html"ID= "SearchText"> # for(X:campuskit.findlistbyaccount (loginaccount))//jfinal statements, loops {{#("#") if(Iscontains ("# (X.campusname)", D.val)) { }}//here is a statement with Layui and Jfinal, # (X.campusname) jfinal statement, {{# ("#") if (Iscontains ("# (X.campusname)", D.val)) {}} In the D.val because if with the Layui statement, so directly write can, generally {{d.val}} This write <input type='checkbox'value="# (X.id)"name='Campus'# (Sysaccountcampusids.contains (x.id.tostring ())? 'checked= "Checked"':"') Title="# (X.campusname)"ID='campusbox# (x.id)'> {{#("#") }}} #end</Script>//str Whether the string contains substr string function Iscontains (str, substr) {return str.indexof (substr) >= 0;} Layui template of the way var gettpl = searchtext.innerhtml;//written to the outside of the JS method to load only once, not every time loading, fast */* Front page Search */function ck (campusname) {//Render Template Layui.laytpl (GETTPL). Render ({"Val": Campusname},//json value function (HTML) {$ ("#cam"). HTML (HTML);//jqu ery loading the template into the div ID is cam<DivID= "Cam"></Div>Console.log (HTML); Layui.form.render (null, "cam"); Update the page in this container}); }
Record learning process ...
Big bro really bad. All kinds of Metropolis ...
Layui+jfinal templates in HTML for front-end search functionality