libs/cbi: preserve tab state across page reloads
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 20 Aug 2009 01:53:24 +0000 (01:53 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 20 Aug 2009 01:53:24 +0000 (01:53 +0000)
libs/cbi/htdocs/luci-static/resources/cbi.js
libs/cbi/luasrc/view/cbi/tabmenu.htm

index 24f929c..2e54ff7 100644 (file)
@@ -235,6 +235,7 @@ function cbi_t_add(section, tab) {
 function cbi_t_switch(section, tab) {
        if( cbi_t[section] && cbi_t[section][tab] ) {
                var o = cbi_t[section][tab];
+               var h = document.getElementById('tab.' + section);
                for( var tid in cbi_t[section] ) {
                        var o2 = cbi_t[section][tid];
                        if( o.tab.id != o2.tab.id ) {
@@ -242,6 +243,7 @@ function cbi_t_switch(section, tab) {
                                o2.container.style.display = 'none';
                        }
                        else {
+                               if(h) h.value = tab;
                                o2.tab.className = o2.tab.className.replace(/(^| )cbi-tab-disabled( |$)/, " cbi-tab ");
                                o2.container.style.display = 'block';
                        }
index e9eb25d..5cd5c76 100644 (file)
@@ -19,7 +19,7 @@ $Id$
                <%- if not self.selected_tab then self.selected_tab = tab end %>
                <li id="tab.<%=self.config%>.<%=section%>.<%=tab%>" class="cbi-tab<%=(tab == self.selected_tab) and '' or '-disabled'%>">
                        <a onclick="this.blur(); return cbi_t_switch('<%=self.config%>.<%=section%>', '<%=tab%>')" href="<%=REQUEST_URI%>?tab.<%=self.config%>.<%=section%>=<%=tab%>"><%=self.tabs[tab].title%></a>
-                       <% if tab == self.selected_tab then %><input type="hidden" name="tab.<%=self.config%>.<%=section%>" value="<%=tab%>" /><% end %>
+                       <% if tab == self.selected_tab then %><input type="hidden" id="tab.<%=self.config%>.<%=section%>" name="tab.<%=self.config%>.<%=section%>" value="<%=tab%>" /><% end %>
                </li>
        <% end end -%>
        </ul>