X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=libs%2Fcbi%2Fhtdocs%2Fluci-static%2Fresources%2Fcbi.js;h=e9a801154840a9c8aa02e3768e6a6c63e0181cc9;hp=4b1849beab9cfe083b0d7ec360c6dd488dc4e6d6;hb=ae6fd93b8ce6b47d68a9ad96e0984edb91ee1716;hpb=ea9b377ec5585bc3a5745a485f84f3fba8a4935a diff --git a/libs/cbi/htdocs/luci-static/resources/cbi.js b/libs/cbi/htdocs/luci-static/resources/cbi.js index 4b1849bea..e9a801154 100644 --- a/libs/cbi/htdocs/luci-static/resources/cbi.js +++ b/libs/cbi/htdocs/luci-static/resources/cbi.js @@ -1,3 +1,18 @@ +/* + LuCI - Lua Configuration Interface + + Copyright 2008 Steven Barth + Copyright 2008 Jo-Philipp Wich + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + $Id$ +*/ + var cbi_d = []; function cbi_d_add(field, dep, next) { @@ -177,3 +192,25 @@ function cbi_filebrowser(id, url, defpath) { browser.focus(); } + +//Hijacks the CBI form to send via XHR (requires Prototype) +function cbi_hijack_forms(layer, win, fail, load) { + layer.select('form').each(function(form) { + form.observe('submit', function(event) { + // Prevent the form from also submitting the regular way + event.stop(); + + var form = event.element(); + + if (load) { + load(); + } + + // Submit via XHR + form.request({ + onSuccess: win, + onFailure: fail + }); + }); + }); +}