Bug when used with AMD (require.js)
See original GitHub issuethe company i am working with likes material design, so i told them about materialize, and they said ok use it , no problem , but currently i am stuck with this so please help !
when i try to require materialize , no errors are shown, but when i actually use it with jquery, it tells me that the method that i am trying to use on that element is undefined here is my code (js):
requirejs.config({
paths: {
'materialize': '../../bower_components/materialize/dist/js/materialize',
'jquery': '../../bower_components/jquery/dist/jquery'
},
shim: {
'materialize': {
deps: ['jquery']
},
'jquery': {
exports: '$'
}
}
});
require(['jquery', 'materialize'], function($) {
$('select').material_select();
});
Screen Shot:
Issue Analytics
- State:
- Created 9 years ago
- Comments:96 (7 by maintainers)
Top Results From Across the Web
Common Errors - RequireJS
If there is no script error in the browser's error console, and if you are using Firebug, try loading the page in another...
Read more >Error trying module loading ( AMD ) with require.js
My js lib directory looks like A). And my App.coffee file looks like B). I've tried to use 'paths' in the require.config and...
Read more >Asynchronous Module Definition (AMD) With RequireJs
When we say an application is modular, we generally mean it's composed of a set of highly decoupled, distinct pieces of functionality stored...
Read more >Understanding AMD & RequireJS · Devbridge
... JavaScript's popularity and provides information on AMD & RequireJS. ... using it, including giants such as jQuery, KnockoutJS, Dojo, EmbedJS and many ......
Read more >Moodle in English: AMD Module moment.js loaded via require ...
Immediately I get the http://requirejs.org/docs/errors.html#mismatch error. Moment.js checks if require.js is present to load AMD modules if so ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@lmadrilejos How about my solution? If it’s hard for you to modify them, check out my forked and modified version: https://github.com/ccloli/materialize/tree/AMD-fix/dist/js
@ZiperRom1 I’ve noticed that Materialize was updated earlier today, but then I almost forgot it, sorry for not updating in time, I’ll updated it ASAP (about 2 hours later) 😃 AFAIK, I guess the reason why Materialize doesn’t support AMD is that some libraries like hammer has already assigned itself as AMD modules, and Materialize concat all the libraries into one single materialize.js. So if we use Materialize as AMD module directly, it may have errors. So here are two solutions: assign all the libraries as single AMD modules (max1011 solution); remove the AMD assigned code of each libraries (my solution). Hope this can help you.😃