-
-
Notifications
You must be signed in to change notification settings - Fork 106
M not defined ... #604
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
Comments
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. |
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 |
https://materializeweb.com/toasts.html "Show Toast" button does not work. Console shows "Uncaught ReferenceError: M is not defined" |
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 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. |
Now each component type is exported, so you can create them directly as
The AutoInit method is exported as a function. So you can use it as
Or call individual components init method:
Of course all this should be explained in the documentation before closing the issue. |
I have solved issues just with changing Materialize version , code on my sites is the same and works nice with version 2.2.1 , 2.2.0 was odd one i think :) thanks for advice @danice and @Jerit3787 |
The website is really not ideal, especially with multiple versions. I think we will have to change the process of the versioning the documentation along with each version of the library. I am thinking we should split the components and make a markdown readme in each component for documentation, which is then compiled to html and aggregated in a new doc version. Edit: See #614 This would be a big change but would solve a lot of issues. I am struggling when it should be done. But probably we should first do 2.2.2 and then step up to 2.3.0. What do you think? |
Sorry that you replied to my deleted comment , I found that whichever version of materialize I declare from cdn in v2 scope after 2.0.4 toast does not work , in 2.2.1 modals are not working either ,they work if you change modal html code and i'm not going to recode 15+ websites I menage every time new version is pushed out . Since version 2.0.4 materialize have issues in every new edit they push . To whoever menages materialize code and making changes - |
Here is a quick and dirty workound I used when supporting multiple versions of materialize.... if (M.toast) { // materialize 2.1.0 M.toast({toastId: 'alertToast', classes: 'rounded'}); } else { // materialize 2.1.1+ new M.Toast({toastId: 'alertToast', classes: 'rounded'}); } |
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
The text was updated successfully, but these errors were encountered: