Closed mevbg closed 9 years ago
Hi,
thank you, that you tried it.
I did not us RequireJS and so I did not tried it.
This line is for support AMD and also RequireJS: https://github.com/tlindig/position-calculator/blob/master/dist/position-calculator.js#L27
Please could you write here what you do to load PositionCalculator? What is your require
statement?
Hi,
I use the minified position-calculator v1.1.2 and the minified jQuery v2.1.3. I concatenate them by using r.js optimizer into a single file - libs.js where jQuery code is first.
Then I just require libs.js before anything else like this:
// Require all libraries
require(['libs'], function () {
// Proceed when the DOM is fully loaded
jQuery(document).ready(function() {
console.log($); // returns jQuery
console.log($.PositionCalculator); // undefined
});
});
IMHO the correct way to use with require.js
should look something like that:
// Require the libraries and get it as parameter
require(["jquery", "position-calculator"], function ($, PositionCalculator) {
// Proceed when the DOM is fully loaded
$(document).ready(function() {
console.log($); // returns jQuery
console.log(typeof PositionCalculator); // Object
});
});
It worked. Thanks!
Hi!
Have you tried to run the plugin by using RequireJS? So far all my tries failed. No matter what I do I end up with undefined $.PositionCalculator in the console and I'm pretty sure I'm doing everything properly. The rest plugins are defined and work fine.
I see in the Developer Toolbar / Network Tab that jQuery is successfully loaded and the plugin is also successfully loaded after jQuery, but $.PositionCalculator is still undefined.
Could it be something that I miss or it's just that RequireJS is not supported?
Regards, Martin