changeset 556badb86238 in sao:4.4
details: https://hg.tryton.org/sao?cmd=changeset;node=556badb86238
description:
Do not use DOM order to find current tab
The DOM and the tabs list are not ensured to have the same order
because the
DOM is modified after the view promise is resolved.
To rely only on a single information source, we store the tab as data
on the
nav li.
issue8443
review249521004
(grafted from d3d2d9a2cc92cf66097bc3f2b9894e247c01ab14)
diffstat:
src/tab.js | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diffs (24 lines):
diff -r 21cd99323005 -r 556badb86238 src/tab.js
--- a/src/tab.js Mon Jul 08 21:26:20 2019 +0200
+++ b/src/tab.js Mon Jul 08 18:51:36 2019 +0200
@@ -227,9 +227,7 @@
return jQuery.when();
};
Sao.Tab.tabs.get_current = function() {
- var tabs = jQuery('#tablist');
- var i = tabs.find('li').index(tabs.find('li.active'));
- return Sao.Tab.tabs[i];
+ return jQuery('#tablist').find('li.active').data('tab');
};
Sao.Tab.tabs.close_current = function() {
var tab = this.get_current();
@@ -275,7 +273,8 @@
'data-placement': 'bottom',
id: 'nav-' + tab.id
}).append(tab_link)
- .appendTo(tablist);
+ .appendTo(tablist)
+ .data('tab', tab);
jQuery('<div/>', {
role: 'tabpanel',
'class': 'tab-pane',