Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M not defined ... #604

Open
VukIgor opened this issue Feb 23, 2025 · 4 comments
Open

M not defined ... #604

VukIgor opened this issue Feb 23, 2025 · 4 comments
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@VukIgor
Copy link

VukIgor commented Feb 23, 2025

Version 2.2.0 does not work for normal developers that need to include css into existing sites ,works with node due to possibility of importing M from materialize ,not so for direct css linking .
If this version is not for normal usage you should say so, not let devs to run for errors everywhere when 2.2.0 is linked to website

@Jerit3787
Copy link

Jerit3787 commented Feb 24, 2025

Hi @VukIgor , could you provide a more detailed errors or a link where we can reproduce the issue? Thanks.

edit: can try using latest version (v2.2.1) and see if the issues still persists.

@VukIgor
Copy link
Author

VukIgor commented Feb 24, 2025

At the moment im using 2.1.1 on few websites. When 2.2.0 is called via link from cdn whole css on site is gone and in console is m is not defined ,materialize modules are called via m.autoinit . however 2.2.0 works on site that is running node js .Did not try 2.2.1, will do tonight . Maybe that 2.2.0 is one of

@uscss-nostromo
Copy link

https://materializeweb.com/toasts.html

"Show Toast" button does not work. Console shows "Uncaught ReferenceError: M is not defined"

@Jerit3787
Copy link

Hi @VukIgor, sorry I just remembered about this issue. I also encountered it when I was upgrading from v2.0.4 to v2.2.0 in my own projects. I couldn't remember the details but I remembered that before this the toast component was refactored before this causing issues including my own project. The refactored also changed from lower case toast to upper case Toast. The changes I did on my project was:

Old implementation:

M.toast({text: "I am a toast"});

New implementation:

new M.Toast({text: "I am a toast"});

It seems like we need to initialize our own M variables before using it. I am not sure if it by design is like that but since you said that in NodeJS environment works well, this might be a valid bug report. But still requires further investigation.

Hi @uscss-nostromo, thanks for reporting as well the documentation issue. There was an issue with the documentation that hasn't been updated to reflect the previous refactor.

I will tag with bug and documentation for this issue for others to investigate.

@Jerit3787 Jerit3787 added bug Something isn't working documentation Improvements or additions to documentation labels Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants