I have three tabs on the page.
<!-- Tabs -->
<div class="mdl-layout__tab-bar">
<a href="#plots-tab" class="mdl-layout__tab is-active"">Plots</a>
<a href="#plots-data-tab" class="mdl-layout__tab">Plots data</a>
<a href="#report-tab" class="mdl-layout__tab">Report</a>
</div>
I need to re-draw plots when Plots tab is selected. I've tried to onclick="redraw_plots();"
to the Plots tab, but function is called too fast before tab is activated. Any way to get an event when this tab activates?
Thank you.
It's happen because element inline event are the first event to be executed.
To Execute after MDL tab event you can do like this:
With Javascript Vanilla:
First add an id on link
Second add an event listener
Or with Jquery:
Add on event listener on element
For me it was not enough to hook to the click event. A timeout of at least 0 milliseconds was necessary otherwise the content display it will still be set to none (tested on Chrome) and any drawing of your own that requires width calculations might fail. Check the attached snippet and verify that without setTimeout, on the click event the tab content display is set to none and not 'block'. MDL must play an animation for smooth transition that cause absolute position drawing issues.