Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to set up my WordPress so that it will use the most recent version of jQuery. Here is what I have done so far:

functions.php

<?
add_action( 'wp_enqueue_scripts', 'RegisterJQuery' );
add_action( 'wp_enqueue_scripts', 'EnqueueScripts' );

function RegisterJQuery()
{
    wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js', false, "1.9.1" );
wp_enqueue_script( 'jquery' );
}

function EnqueueScripts()
{
    wp_enqueue_script('karate', THEME_DIRECTORY . '/js/karate.js', 'jquery');
}

So everything in my 'karate' .js file is working as expected (including an alert that confirms that the version of jQuery has indeed been updated). However, my theme (Elegant Theme Chameleon) uses a mouseover effect on its menu to show submenus and this effect does not work anymore.

How can I figure out what is going on? My understanding is that if something was not compatible with the newer version of jQuery, it would still work if I upgraded the version (because of no-conflict mode). What do you think?

William

share|improve this question
    
It's probably using hover which I think has been deprecarted in the latest version. –  elclanrs Apr 3 '13 at 6:05
    
Is there a good way to fix it easily? –  William Apr 3 '13 at 6:25
    
Using the jQuery migrate plugin is the easiest way to fix it. –  RRikesh Apr 3 '13 at 6:35
1  
It will break other code too, because Google's jQuery doesn't run in noConflict() mode. Never replace the internal jQuery. –  toscho Apr 3 '13 at 7:24
    
Google's jQuery? –  William Apr 3 '13 at 16:15

1 Answer 1

According to this article:

"hover" pseudo-event

As of 1.9, the event name string "hover" is no longer supported as a synonym for "mouseenter mouseleave". This allows applications to attach and trigger a custom "hover" event. Changing existing code is a simple find/replace, and the "hover" pseudo-event is also supported in the jQuery Migrate plugin to simplify migration.

If you need to continue using hover() you may use the Migrate plugin.

Change your function to:

function RegisterJQuery()
{
    wp_deregister_script( 'jquery' );
    wp_register_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js', false, "1.9.1" );
    wp_enqueue_script( 'jquery' );
    wp_register_script( 'migrate', 'http://code.jquery.com/jquery-migrate-1.1.1.min.js');
    wp_enqueue_script( 'migrate' );
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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