Good day,
I have a project that uses materializecss with jQuery. I have a DOM that is already filled with materialize elements, everything works wonderfully there.
However, as soon as I generate a "popup" that contains new DOM elements (such as a datepicker) they do not work. According to the documentation I could read that an M.AutoInit() is running at the beginning and therefore the elements are not yet initialized.
How do I ensure that all elements - whether popup or not - always work?
If I try to initialize a date selector again, I get the following error:
materialize.min.js:6 Uncaught TypeError: Right-hand side of 'instanceof' is not callable
This is how it worked for the elements not included in the popup:
$('.datepicker').datepicker(<options>);
CodePudding user response:
I found the problem. Inside my script where I create those popups, there is a variable named "Element". Its a class attribute. I wanted to override it but without a this, cuz javascript ist flexible with this. The problem was now exactly, that materializecss has a variable named "Element", too. So I changed this one and triggered a error with $(".datepicker").datepicker();
.