changeset 796ee132aed8 in sao:5.2
details: https://hg.tryton.org/sao?cmd=changeset;node=796ee132aed8
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 ec5d25a3d95b -r 796ee132aed8 src/tab.js
--- a/src/tab.js Wed Jul 17 22:50:25 2019 +0200
+++ b/src/tab.js Mon Jul 08 18:51:36 2019 +0200
@@ -336,9 +336,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();
@@ -396,7 +394,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',