Forums

jQuery enqueue_script breaking jQuery Objects (8 posts)

  1. jet71dl
    Member
    Posted 1 year ago #

    Not sure what's going on. I added the following:

    if ( !is_admin()){
    	wp_deregister_script('jquery');
    	wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"), false, '1.4.3');
    	wp_enqueue_script('jquery');
    }

    to correctly load jQuery into WordPress and it shows it being loaded in the code <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js?ver=1.4.3'></script>
    But the items I have using jQuery are broken like the script isn't loading.

    If I manually add the jQuery script into the header and delete the jquery.js file from the wp-includes folder, the items work correctly (but the admin area jQuery items stop working...).

    Anyone know why this is happening?
    Thanks.

  2. coopersita
    Member
    Posted 1 year ago #

    Change the jQuery first line in your script (not in plugin files, though, just the code that checks if the document is ready) to:

    jQuery(document).ready(function($){

    I'm not 100% sure why this is, but maybe someone could illuminate us.

  3. jet71dl
    Member
    Posted 1 year ago #

    Well, I already have it checking if the document is ready:

    $(document).ready(function(){
    	$('#portfolio-list').filterable();
    });

    But it still doesn't work. Thoughts?

    Even changing it to your suggestion:

    jQuery(document).ready(function($){
        $('#portfolio-list').filterable();
    });

    Doesn't work.

  4. coopersita
    Member
    Posted 1 year ago #

    Link, please. Hard to tell what's wrong when you can't see the error messages.

  5. jet71dl
    Member
    Posted 1 year ago #

    That's the thing, it's not throwing any error messages.

    But, you can see it here: http://shanehowell.com/testing/

    The large box on top is supposed to have a slideshow going and the thumbnails below that are supposed to be on a single scrollable line with filtering. Plus the background image is brought in by jQuery also, which no longer comes in.

    The menu on the side doesn't use jQuery so it works fine.

  6. jet71dl
    Member
    Posted 1 year ago #

    Ok, i've also narrowed it down to a plugin, when I activate it it kills the jQuery objects I have and when I deactivate it they come back to life.

    The plugin is Photo Galleria which allows customization to the default WP [gallery] code. So I don't understand why that would kill the other objects.

  7. coopersita
    Member
    Posted 1 year ago #

    You also have multiple calls to the ready function. To debug this, I would comment out all the jquery (and other javascripts as well), except for one, and then do something simple inside, like:

    jQuery(document).ready(function($){
    alert('test');
    });

    Then, I'd add all my jquery code inside that call to ready. I find that multiple calls to it cause issues.

    Hope this helps

  8. jet71dl
    Member
    Posted 1 year ago #

    Thanks for your help! I'll be sure to condense my ready calls.

    I did fix the issue that the Plugin was causing by going into it's script and deleting the call to load jQuery that it was making.

    I probably should of looked for that first!

Topic Closed

This topic has been closed to new replies.

About this Topic