diff options
author | Jo-Philipp Wich <jo@mein.io> | 2021-04-09 14:36:19 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2021-04-09 14:36:19 +0200 |
commit | 36959dc0d10bd012f35c51bf8a6b88ce6c5853a2 (patch) | |
tree | be3c2ba9f755870016098cfab18f1f31db309472 /applications/luci-app-commands/luasrc/view | |
parent | f117b7f1ec3b582aeed524093afc06dd5eb15127 (diff) |
luci-app-commands: prevent page reload on invoking command actions
Fixes: f117b7f ("luci-app-commands: use <button> elements")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'applications/luci-app-commands/luasrc/view')
-rw-r--r-- | applications/luci-app-commands/luasrc/view/commands.htm | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/applications/luci-app-commands/luasrc/view/commands.htm b/applications/luci-app-commands/luasrc/view/commands.htm index ff82eac47a..634090e7d7 100644 --- a/applications/luci-app-commands/luasrc/view/commands.htm +++ b/applications/luci-app-commands/luasrc/view/commands.htm @@ -37,7 +37,7 @@ <script type="text/javascript">//<![CDATA[ var stxhr = new XHR(); - function command_run(id) + function command_run(ev, id) { var args; var field = document.getElementById(id); @@ -83,9 +83,11 @@ } ); } + + ev.preventDefault(); } - function command_download(id) + function command_download(ev, id) { var args; var field = document.getElementById(id); @@ -93,9 +95,11 @@ args = encodeURIComponent(field.value); location.href = '<%=url('admin/system/commands/download')%>/' + id + (args ? '/' + args : ''); + + ev.preventDefault(); } - function command_link(id) + function command_link(ev, id) { var legend = document.getElementById('command-rc-legend'); var output = document.getElementById('command-rc-output'); @@ -122,6 +126,8 @@ location.hash = '#output'; } + + ev.preventDefault(); } //]]></script> @@ -156,10 +162,10 @@ <p><%:Arguments:%> <input type="text" id="<%=command['.name']%>" /></p> <% end %> <div> - <button class="cbi-button cbi-button-apply" onclick="command_run('<%=command['.name']%>')"><%:Run%></button> - <button class="cbi-button cbi-button-download" onclick="command_download('<%=command['.name']%>')"><%:Download%></button> + <button class="cbi-button cbi-button-apply" onclick="command_run(event, '<%=command['.name']%>')"><%:Run%></button> + <button class="cbi-button cbi-button-download" onclick="command_download(event, '<%=command['.name']%>')"><%:Download%></button> <% if command.public == "1" then %> - <button class="cbi-button cbi-button-link" onclick="command_link('<%=command['.name']%>')"><%:Link%></button> + <button class="cbi-button cbi-button-link" onclick="command_link(event, '<%=command['.name']%>')"><%:Link%></button> <% end %> </div> </div> |