2

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!

1 Answer 1

3

Looking at the JQPlot code, the whole plugin is declared within a closure:

(function($) { 
  // JQPlot code
})(jQuery);

So the plugin is fine ($ = jQuery in the plugin scope). However, the effects declaration is not:

var backCompat = $.uiBackCompat !== false;
// And then, JQPlot effects declaration

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 the jquery.jqplot.js.

Edit

The latest stable version (0.9.7r635) seems not to have this issue. Maybe give it a try !

1
  • 1
    uh... version 1.0.2r1108 seems to have this issue again :S
    – danieleds
    Jul 29, 2012 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.