添加按钮,实现页面跳转
1、在~/luci/modules/admin-full/luasrc/model/cbi/admin_network/wifi_client.lua添加
o = s:taboption("general", DummyValue, "_scan", translate("Scan ")) o.template = "admin_network/scan_result"
2、在~/luci/modules/admin-full/luasrc/view/admin_network添加scan_result.htm文件
<%+cbi/valueheader%> <script type="text/javascript">//<![CDATA[ function scan_click(btn) { btn.disabled = true; btn.value = '<%:Scanning...%>'; location.href='<%=luci.dispatcher.build_url("admin/network/wireless_join")%>?device=<%="radio0"%>'; return false; } //]]></script> <input type="button" class="cbi-button cbi-button-apply" value="<%:Scan%>" onclick="return scan_click(this)" /> <%+cbi/valuefooter%>
补充:
如果在lua文件中,只实现跳转,可用:
local myurl = luci.dispatcher.build_url("admin/network/wireless_join") .. "?device=radio0" luci.http.write("<script>location.href='"..myurl.."';</script>")