tingpan

生命不息,折腾不止!
  首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

添加按钮,实现页面跳转

Posted on 2015-01-08 11:56  tingpan  阅读(1663)  评论(0编辑  收藏  举报

添加按钮,实现页面跳转

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>")