From f8634e07574d4d68eccb0a5fafdac69b9a7270ce Mon Sep 17 00:00:00 2001 From: Ben Thomson Date: Wed, 19 Feb 2020 10:49:15 +0800 Subject: [PATCH] Immediately load a lazy tab if it is the initial active tab. Fixes #4879 --- modules/backend/widgets/form/assets/js/october.form.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/backend/widgets/form/assets/js/october.form.js b/modules/backend/widgets/form/assets/js/october.form.js index 932b8bebf..6d1e7ded2 100644 --- a/modules/backend/widgets/form/assets/js/october.form.js +++ b/modules/backend/widgets/form/assets/js/october.form.js @@ -166,7 +166,10 @@ * Render tab form fields once a lazy tab is selected. */ FormWidget.prototype.bindLazyTabs = function() { - this.$el.on('click', '.tab-lazy [data-toggle="tab"]', function() { + var tabControl = $('[data-control=tab]', this.$el), + tabContainer = $('.nav-tabs', tabControl) + + tabContainer.on('click', '.tab-lazy [data-toggle="tab"]', function() { var $el = $(this), handlerName = $el.data('tab-lazy-handler') @@ -191,6 +194,11 @@ } }) }) + + // If initial active tab is lazy loaded, load it immediately + if ($('> li.active.tab-lazy', tabContainer).length) { + $('> li.active.tab-lazy > [data-toggle="tab"]', tabContainer).trigger('click') + } } /*