layui搜索框的重置按钮,重置功能怎么实现?
<div class="layui-form-item " >
<button class="layui-btn" type="button" id="${formId}Search">搜索</button>
</div>
</div>
<!--重置按钮-->
<div class="layui-form-item " >
<button class="layui-btn" type="button" id="reset">重置</button>
</div>
只需要将type=“button” 改为type=“reset”,重置功能自动生效
<button class="layui-btn" type="reset" id="reset">重置</button>
搜索功能的实现
/* 初始化搜索 */
initSearchForm : function(form, tableIns, layuiForm) {
id = form.attr("id");
Lib.initGenrealForm(form, layuiForm)
var btn = $("#" + id + "Search")
btn.on('click', function() {
Lib.doSearchForm(form, tableIns, 1);
});
},
btn.on('click', function() {
var data = form.serializeJson()
if (page != null) {
tableIns.reload({
where : data,
page: {
curr: page
}
});
} else {
tableIns.reload({
where : data
});
}
})