I included a Graphing and Plotting Jquery library called JQplot with wordpress using the following code in my functions.php file:
function rw_jqplot() {
// JS
wp_deregister_script('jqplot');
wp_enqueue_script('jqplot', plugins_url('/js/jquery.jqplot.min.js', __FILE__), array("jquery"), '1.0.0.1012');
// CSS
wp_deregister_style('jqplot');
wp_enqueue_style('jqplot', plugins_url('/css/jquery.jqplot.min.css', __FILE__), false, '1.0.0.1012');
} add_action('init', 'rw_jqplot');
?>
The problem is that I get an error that says (in firebug): $ is undefined.
I did some research and I think that it has to do something with jquery running in no conflict mode. So maybe a solution to this is to somehow include the above code within the wordpress no conflict mode? is that possible to do?
Thanks!
Looking at the JQPlot code, the whole plugin is declared within a closure:
So the plugin is fine (
$ = jQueryin the plugin scope). However, the effects declaration is not:That’s an issue, and you should report it to the development team. For a quick&dirty fix, you can add
(function($) {at the line 10577 and})(jQuery);at the end of thejquery.jqplot.js.Edit
The latest stable version (0.9.7r635) seems not to have this issue. Maybe give it a try !