Using inline javascript I am trying to scroll to a section after loading a particular tab.
setTimeout(function(){
$(".multimediaList a").click(function(event){
// loads tab
$("li#abc").click();
// trigger scrolling to a section and open a popup
var sectionId = event.target.getAttribute("data-sectionId");
var sectionImageId = event.target.getAttribute("data-sectionImageId");
setTimeout(function(){
TRLSC.SI.aJsClass.loadSection(sectionId, sectionImageId);
},1000)
})
})
Here is load section function defined in an js file. We are using angularjs framework
loadSection: function(b, a) {
$("#DBsection_" + b).addClass("unloaded");
TRLSC.SI.aJsClass.showDiv(b, a);
TRLSC.SI.aJsClass.showSection(b);
$("#DBsection_" + b).removeClass("unloaded");
$("#DBsection_" + b).show()
},
Here is show div function
showDiv: function(b, a) {
$("#DBtitle_" + b).parent().addClass("is-expanded");
$("#DBtitle_" + b).addClass("accordian-holder-titleDBopened");
$("#icon_" + b).addClass("accordian-holder-indicatorOpened");
$("#icon_" + b).removeClass("accordian-holder-indicator");
TRLSC.SI.aJsClass.dbLoadContent(b, a);
TRLSC.SI.aJsClass.changeText()
},
the issue with this approach is that sometimes dbLoadContent is triggering before the tab has loaded and is not scrolling to the section, also there is no error in the console.
How to make sure that click event happens when tab finish loading!