Title: Including jQuery breaks dashboard JavaScript
Last modified: August 19, 2016

---

# Including jQuery breaks dashboard JavaScript

 *  [John](https://wordpress.org/support/users/sidewindernet/)
 * (@sidewindernet)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/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?

Viewing 10 replies - 1 through 10 (of 10 total)

 *  Thread Starter [John](https://wordpress.org/support/users/sidewindernet/)
 * (@sidewindernet)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/including-jquery-breaks-dashboard-javascript/#post-1525933)
 * Anyone have any ideas?
 *  [Andy Potanin](https://wordpress.org/support/users/andypotanin/)
 * (@andypotanin)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/including-jquery-breaks-dashboard-javascript/#post-1525989)
 * UI Widget causes that error. In case your particular plugins/theme does not need
   the UI Widget file, download the UI files separately, and only use the ones you
   need.
 *  [Brig01](https://wordpress.org/support/users/brig01/)
 * (@brig01)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/including-jquery-breaks-dashboard-javascript/#post-1525995)
 * Sorry to bring an old thread back to life but I’m having this exact problem on
   a new theme I’m building.
 * I’ve implemented jQuery UI Datepicker in one of my custom post types and while
   it works fine, loading the latest version of jQuery UI breaks the draggable widgets
   on the wordpress admin.
 * Here’s how I’m loading jQuery UI:
 *     ```
       function jquery_ui_initialise()
       {
       	#PAGE IS ADMIN
       	if(is_admin())
       	{
       		#DEREGISTER DEFAULT JQUERY INCLUDES
       		wp_deregister_script('jquery-ui-core');
       		wp_deregister_script('jquery-ui-tabs');
       		wp_deregister_script('jquery-ui-sortable');
       		wp_deregister_script('jquery-ui-draggable');
       		wp_deregister_script('jquery-ui-droppable');
       		wp_deregister_script('jquery-ui-selectable');
       		wp_deregister_script('jquery-ui-resizable');
       		wp_deregister_script('jquery-ui-dialog');
   
       		#LOAD THE GOOGLE API JQUERY INCLUDES
       		wp_register_script('jquery_ui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js', false, '1.8.2', false);
   
       		#REGISTER CUSTOM JQUERY INCLUDES
       		wp_enqueue_script('jquery_ui');
       	}
       }
   
       #INITIALISE JQUERY LIBRARY
       add_action('init', 'jquery_ui_initialise');
       ```
   
 * The date picker requires the UI Widget so I’m not sure what to do.
 * Does anyone have a fix for this please? I just need to get the date picker working.
 *  [Andy Potanin](https://wordpress.org/support/users/andypotanin/)
 * (@andypotanin)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/including-jquery-breaks-dashboard-javascript/#post-1525997)
 * Go to [http://jqueryui.com/download](http://jqueryui.com/download) and download
   the 1.7.3 version of the datepicker, and use the built-in WP ui library.
 *  [Andy Potanin](https://wordpress.org/support/users/andypotanin/)
 * (@andypotanin)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/including-jquery-breaks-dashboard-javascript/#post-1525998)
 * In fact that’s what I have to do all the time with a lot of jQuery scripts to
   keep WP from breaking, just downgrade the version, and it’ll work.
 *  [oOSilasOo](https://wordpress.org/support/users/oosilasoo/)
 * (@oosilasoo)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/including-jquery-breaks-dashboard-javascript/#post-1526012)
 * Sorry to revive the post again, again. I want to use jquery ui autocomplete so
   I cant downgrade.
 *     ```
       wp_enqueue_script('widget',MY_THEME_PATH . '/custom/jquery.ui.widget.js');
           wp_enqueue_script('jquery-ui-mouse',MY_THEME_PATH . '/custom/jquery.ui.mouse.js',array('widget'));
   
           wp_deregister_script( 'jquery-ui-core' );
           wp_enqueue_script( 'jquery-ui-core', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.min.js',array('jquery-ui-mouse'));
       ```
   
 * I am getting `this._mouseInit is not a function` any ideas?
 *  [Steven](https://wordpress.org/support/users/spstieng/)
 * (@spstieng)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/including-jquery-breaks-dashboard-javascript/#post-1526013)
 * I’m having the same problem. Not sure what to do.
    I will not downgrade my scripts
   since that’s not really a good approach.
 * What UI scripts are by default loaded by WP?
 * [@silas](https://wordpress.org/support/users/silas/): You must load UI Core bedfore
   any other UI scripts.
    You have also made UI Core dependent on jquery-ui-mouse,
   that’s wrong. It should be the other way.
 *  [Steven](https://wordpress.org/support/users/spstieng/)
 * (@spstieng)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/including-jquery-breaks-dashboard-javascript/#post-1526014)
 * This worked for me:
 *     ```
       wp_deregister_script('jquery-ui-core','jquery-ui-dialog');
       wp_register_script('jquery-ui','http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.js',array('jquery'));
       wp_enqueue_script('jquery-ui');
       ```
   
 *  [oOSilasOo](https://wordpress.org/support/users/oosilasoo/)
 * (@oosilasoo)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/including-jquery-breaks-dashboard-javascript/#post-1526015)
 * haha! worked for me. this is what I did for auto complete.
 *  `wp_deregister_script(‘jquery-ui-core’,’jquery-ui-dialog’);
    wp_register_script(‘
   jquery-ui’,’[http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.js&#8217](http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.js&#8217);,
   array(‘jquery’)); wp_enqueue_script(‘jquery-ui’);
 *  wp_enqueue_script(‘widget’,MY_THEME_PATH . ‘/custom/jquery.ui.widget.js’);
    
   wp_enqueue_script(‘position’,MY_THEME_PATH . ‘/custom/jquery.ui.position.js’);
   wp_enqueue_script(‘autocomp’,MY_THEME_PATH . ‘/custom/jquery.ui.autocomplete.
   js’,array(‘jquery-ui’,’jquery-ui-core’,’widget’,’position’));`
 * thanks for the help.
 *  [oOSilasOo](https://wordpress.org/support/users/oosilasoo/)
 * (@oosilasoo)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/including-jquery-breaks-dashboard-javascript/#post-1526016)
 * hhm, doing it this way seems to have killed my tags matabox…the place holder 
   text does not go away and the ajax script doesn’t get called. [@spstieng](https://wordpress.org/support/users/spstieng/)
   are you having this problem? edit: It has actually killed all the JS on my edit
   posts page.

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Including jQuery breaks dashboard JavaScript’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 10 replies
 * 5 participants
 * Last reply from: [oOSilasOo](https://wordpress.org/support/users/oosilasoo/)
 * Last activity: [15 years, 6 months ago](https://wordpress.org/support/topic/including-jquery-breaks-dashboard-javascript/#post-1526016)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
