question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug when used with AMD (require.js)

See original GitHub issue

the 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: image

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:96 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
cclolicommented, Mar 13, 2016

@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

1reaction
cclolicommented, Jul 24, 2016

@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.😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found