Closed ChuyUX closed 9 years ago
I would recommend to take a look at the RequireJS docs again :)
First of all you need a config to define the path to your files e.g.
require.config({
paths: {
'jquery': 'path/to/jquery',
'rangeslider': 'path/to/rangeslider'
...
}
});
Now you can define your modules e.g
define([
'jquery',
'rangeslider'
], function ($, rangeslider) {
$('input[type="range"]').rangeslider({
polyfill: false
});
});
Well, I forgot to mentioned and share that. I actually have this require.config with the each path defined as you put it previously. But, as I told you, this sometimes works and sometimes doesn't. I actually have another AMD ready plugins, like Slick, and it always works. So I know that someting I'm doing right. I don't know if there is an error in the way you built the script to be AMD
K sorry no idea then. But the code how you load the modules doesn't look right to me. I personally use this plugin in an AMD environment and it works perfectly with the code posted above.
Hello, I'm trying to call this script in RequireJS. Knowing that this plugins it's AMD enable, the definition that I'm using is this.
define(function (require) { var $ = require('jquery'), rangeslider = require('rangeslider'); $('input[type="range"]').rangeslider({ polyfill: false }); });
But sometimes, this doesn't work, and gets me an error: TypeError: $(...).rangeslider is not a function Hope you can help me out with this issue Thanks