By danieleds on
Hi, I'm developing my first Drupal module and I need to use an external js library (jqplot).
Now, I wrapped my "document.ready" code inside "(function ($) { })(jQuery);", but I still get an error: "$ is undefined".
I think the problem is inside jqplot, which uses the $ sign to refer to jQuery. Of course, I'd like to avoid replacing all occurrences of "$" inside this 3rd party library...
This is my code:
jQuery(document).ready(function() {
(function ($) {
var plot1 = $.jqplot ('chart1', [[3,7,9,1,4,6,8,2,5]]);
})(jQuery);
});And this is how I load the scripts:
drupal_add_css(drupal_get_path('module', 'myapp') .'/src/libs/jqplot/jquery.jqplot.min.css');
drupal_add_js(drupal_get_path('module', 'myapp') .'/src/libs/jqplot/jquery.jqplot.min.js');
Am I missing something?
Thank you!
Comments
_
Maybe see how the data_visualization or newsletter modules use jqplot.
Thanks! By reading
Thanks! By reading newsletter's code I discovered that it seems to be a jqplot bug:
http://stackoverflow.com/questions/10669585/is-undefined-error-in-wordpr...