我在HTML表单内使用Jquery Query Builder<script type="text/javascript"> ...... ...... var filter_json2 = <%=jsonArray%>; console.log(<%=jsonArray.toString()%>); $(document).ready(function(){ $('#rule_div').queryBuilder({ plugins:['bt-tooltip-errors'], filters:filter_json2 }); $('#btn_reset').on('click', function () { $('#rule_div').queryBuilder('reset'); }); $('#btn_set').on('click', function () { $('#rule_div').queryBuilder('setRules', rules_basic); }); $('#btn_get').on('click', function () { var result = $('#rule_div').queryBuilder('getRules'); if (!$.isEmptyObject(result)) { //alert(JSON.stringify(result, null, 2)); $("#jsonRule").val(JSON.stringify(result, null, 2)); console.log(result); } }); }); ...... ......</script> ...... ...... ...... ......<form action="/jspfile.do" method="post"> ...... ...... other fields in form ...... ......<tr> <td></td> <td> <div id="rule_div"> <button class="btn_set" id="btn_set">Set Rules</button> <button class="btn_get" id="btn_get">Get Rules</button> <button class="btn_reset" id="btn_reset">Reset</button> </div> <input type="hidden" id="jsonRule" name="jsonRule" value=""> </td></tr></form>当我从查询生成器中选择某项并单击“获取规则”按钮时,我获取的是json规则,但是页面正在刷新,并且我选择的任何内容都将被擦除。演示不是这种情况,我指的是[ https://querybuilder.js.org/demo.html]谁能建议我,如何防止刷新后从查询生成器中删除选定的数据?
添加回答
举报
0/150
提交
取消