Skip to:
Content
Pages
Categories
Search
Top
Bottom

jQuery conflict(s) – any experts around?

  • Avatar of thebloghouse
    thebloghouse
    Participant

    @thebloghouse

    Hi all

    Has anyone got any custom jQuery scripts playing nice with BuddyPress 1.0.1. and are you able to help a jQuery novice with something probably really easy?

    Basically when I have <?php wp_head(); ?> loading, any code I have in a custom.js file doesn’t seem to work.

    e.g something simple like the following that is meant to slide a login form in and out when you click the link doesn’t work:

    $(document).ready(function () {
    $('a.menu_class').click(function () {
    $('div#login-form').slideToggle('medium');
    });
    });

    I have found reference to the wp enqueue script and am wondering if I should be using the following syntax to load custom javascript in WordPress at page load instead?

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

    I have tried the above systax instead but it still doesn’t work so I think I am missing something quite fundamental to do with BuddyPress and jQuery :(

    p.s Something like the end result I am trying to accomplish can be seen here

Viewing 3 replies - 1 through 3 (of 3 total)
  • Avatar of thebloghouse
    thebloghouse
    Participant

    @thebloghouse

    I have managed to answer my own question but thoguht I would post a follow up in case any other jQuery newbies run into this.

    Basically you can load your own jQuery scripts safely by putting jQuery into “no conflict” mode and then use a different shortcut for jQuery:

    var $j = jQuery.noConflict();

    // Use jQuery via $j(...)
    $j(document).ready(function(){
    $j("#panel").slideToggle("slow");
    etc

    Hope this help someone in the future as this had me really scratching my head and losing MANY hours :(

    Avatar of Paul Gibbs
    Paul Gibbs
    Keymaster

    @djpaul

    Just use jQuery(…) rather than $(…)

    Avatar of thebloghouse
    thebloghouse
    Participant

    @thebloghouse

    I tried that Paul and it didn’t seem to work with the functions I was using – no idea why!!

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

You must be logged in to reply to this topic.