Including jQuery breaks dashboard JavaScript
-
I’ve been working on a few admin dashboard widgets for my plugin. Recently I noticed that I cannot sort any widgets on the dashboard. Firebug is reporting the following error:
this._mouseInit is not a function
I also recently upgraded to WordPress 3.0 RC2. My plugin also comes with jQuery, and I updated that from version 1.7 to 1.8. I’ve just noticed this issue, and I’m not sure if it from updating jQuery, WordPress, or just poor coding on my part.
The error happens when I include jQuery UI (jquery-ui-1.8.2.custom.min.js).
public function admin_init () { $plugin = "temp"; $scripts = array("/$plugin/js/jquery-1.4.2.min.js", "/$plugin/js/jquery-ui-1.8.2.custom.min.js", "/$plugin/js/functions.js"); for($i = 0; $i < count($scripts); $i++) { $url = WP_PLUGIN_URL . $scripts[$i]; $file = WP_PLUGIN_DIR . $scripts[$i]; if (file_exists($file)) { wp_register_script($plugin . '_script_' . $i, $url); wp_enqueue_script($plugin . '_script_' . $i); } } }
This function is called using the admin_init hook. Just to be clear, if I remove the following line
"/$plugin/js/jquery-ui-1.8.2.custom.min.js",
The WordPress dashboard JavaScript works (FireBug no longer reports an error), but my code does not work because it uses that JavaScript file.What do I need to do to fix this issue?
- The topic ‘Including jQuery breaks dashboard JavaScript’ is closed to new replies.