Commit 4d9c716eb7ecada8a8e7e4aa21a2c35a8de859af

Authored by Julien Verneuil
1 parent bc9219ca

make jquery tabs retain the previously active tab for all forms submit action in the tab content

Showing 1 changed file with 32 additions and 5 deletions   Show diff stats
web/jQuery/CXM_jquery_tabs.anubis
... ... @@ -9,6 +9,7 @@
9 9  
10 10 read calexium_lib/web/CXM_making_a_web_site.anubis
11 11 read calexium_lib/web/CXM_jquery.anubis
  12 +read calexium_lib/web/CXM_common.anubis
12 13 read tools/basis.anubis
13 14  
14 15 public type JQuery_tab:
... ... @@ -69,18 +70,37 @@ define HTML_Partial_Content
69 70 }
70 71 .
71 72  
72   -
73 73 public define HTML_Partial_Content
74 74 jquery_tabs
75 75 (
76 76 String tabs_container_id,
77   - List(JQuery_tab) tabs
  77 + List(JQuery_tab) tabs,
  78 + List(Web_arg) lwa
78 79 )
79 80 =
  81 + with index_str = if web_arg_value(lwa, "jq_tabs_" + tabs_container_id) is
  82 + {
  83 + not_found then "0",
  84 + found(ps) then ps
  85 + },
80 86 if _jquery_tabs(tabs_container_id, tabs, "", [], [], 0) is partial_content(tags, html) then
81 87 partial_content(
82 88 [
83   - js_inline(jquery_ready("$('#"+tabs_container_id+"').tabs();"))
  89 + js_inline(jquery_ready("
  90 + $('#"+tabs_container_id+"').tabs({
  91 + active: " + index_str + ",
  92 + activate: function( event, ui ) {
  93 + ui.newPanel.find('input[name=jq_tabs_" + tabs_container_id + "]').each(function () {
  94 + $(this).attr('value', ui.newTab.index());
  95 + });
  96 + },
  97 + create: function( event, ui ) {
  98 + $('#"+tabs_container_id+"').find('form').prepend('<input type=\"hidden\" name=\"jq_tabs_" + tabs_container_id + "\" value=\"'+ui.tab.index()+'\">');
  99 + }
  100 + });
  101 +
  102 +
  103 + "))
84 104 .
85 105 tags
86 106 ],
... ... @@ -89,6 +109,13 @@ public define HTML_Partial_Content
89 109 html,
90 110 literal("</div>")
91 111 ])
92   - )
93   - .
  112 + ).
94 113  
  114 +public define HTML_Partial_Content
  115 + jquery_tabs
  116 + (
  117 + String tabs_container_id,
  118 + List(JQuery_tab) tabs
  119 + )
  120 + =
  121 + jquery_tabs(tabs_container_id, tabs, []).
... ...