Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Materialize active tab not working in Modal

The active tab doesn't show an underline when in a Modal even though I have given one of the tabs a class of active. However, once I click on one of the tabs it starts working. What is the issue?

Here is a JSFiddle.

And here is the spot where I'm giving the element the proper class name:

...
<a class="active" href="#test1">Test 1</a>
...

Any help would be appreciated.

like image 526
Saad Avatar asked Jul 31 '16 13:07

Saad


1 Answers

The underline will show if you initialize the tabs using the ready option of the Modal window.

Something like this:

$('.modal-trigger').leanModal({
    ready: function () {
        $('ul.tabs').tabs();
    }
});

Here is a fiddle: https://jsfiddle.net/powxw392/

If you want a bit of an animation when you pop the modal window, place the tabs initialization outside of the modal function and add a click event like so:

$('ul.tabs').tabs();
$('.modal-trigger').leanModal({
    ready: function () {
        $('#firstTab').click();
    }
});

fiddle: https://jsfiddle.net/qj0r84dr/

Both options will allow you to retain the animation of the underline moving from tab to tab.

like image 162
Dryden Long Avatar answered Nov 15 '22 04:11

Dryden Long