I want to unify the navigation layout for my website, so I created a separate html file that holds the code for the navigation. I use a JS to load the file dynamically:
$("#navigation").load("/navigation/navigation.html", function() {
$.getScript('/material.min.js');
});
The problem is that the material.min.js does not get executed for the dynamically loaded components inside this html and I lose some crucial functionality. How do I fix that?
Check if the
componentHandler
is loaded, and try to upgrade the elements after load.How the Component Handler works
From the official docs:
So loading the material.js script again will not execute it. But you can do some experiments with
upgradeElements
by applying it to the whole loaded markup or to particular elements.