WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Resolving jQuery Conflicts in jQuery Plugins (13 posts)

  1. Glenn Ansley
    Member
    Posted 6 years ago #

    I want to use a jQuery plugin (not a WP plugin) but the JS in the plugin uses the default '$' rather than WP's 'jQuery' to identify itself. In order to make this work with WP, do I need to change the code in the plugin or is there a hook/filter I can invoke to correct this?

    Thanks.

    clarification: installing, linking to the jQuery plugin is not the issue.

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    As long as you don't load or need prototype, jQuery's load should take the $ symbol and that's what it'll be linked to. WordPress doesn't call jQuery.noConflict() anywhere, I think.

  3. Lester Chan
    Member
    Posted 6 years ago #

    Apparently, I am using jQuery() instead of $() as I think WordPress uses jQuery(). Open up wp-includes/js/thickbox/thickbox.js and you will see that it is using jQuery() instead of $(). The default thickbox comes with $().

  4. Glenn Ansley
    Member
    Posted 6 years ago #

    I was using jQuery rather than $ because that's the only way I could get it to work in my WP Plugin functions. Strangely enough though, the jQuery plugin I am using right now is working okay with the $ rather than the jQuery notation.

    I guess I'll be okay if I don't use prototype, I just can't figure why

    $(document).ready(function(){
      blah blah blah
    });

    won't work in my plugin's function but

    jQuery(document).ready(function(){
      blah blah blah
    });

    does work.

  5. Alphawolf
    Member
    Posted 6 years ago #

    I just faced exactly the same issue. $ function calls within WP return an error in my Firebug. When I include another jQuery.js file, it returns an error aswell:

    jQuery("#media-buttons a").tTips is not a function
    http://www.domain.de/folder/wp-admin/js/common.js?ver=20080318
    Line 45

    So, do plugin authors have to modify jQuery plugins for using with WP?

    Odd.

  6. Roger Theriault
    Member
    Posted 6 years ago #

    To avoid conflicts (which can crop up when users install other plugins), you'll probably need to change the $ references.

    See this post: JQuery and jQueryUI

  7. Roger Theriault
    Member
    Posted 6 years ago #

    PS

    The author of the JQuery Validation plugin, Jörn Zaefferer, pointed out on the Google jQuery forum the correct format that you should typically see in a jQuery plugin (ie js file)

    http://docs.jquery.com/Plugins/Authoring#Custom_Alias_in_plugin_code

    He also said if jQuery authors don't use this format and it causes problems, it's a bug in the JavaScript file and should be reported as such.

  8. rahul286
    Member
    Posted 6 years ago #

    I encountered same error as Alphawolf.

    jQuery("#media-buttons a").tTips is not a function
    http://localhost/blog/wp-admin/js/common.js?ver=20080318
    Line 45

    Surprisingly I am using jQuery everywhere, instead of my $ in my code.
    In face I tried removing all code from my js file but no use.

    I think common.js throws error before custom js file can be reached.

    Now possible solution could be to figure out why common.js is throwing error and fix it.

    Please help me/correct me if I am wrong.

  9. Roger Theriault
    Member
    Posted 6 years ago #

    @rahul286 and Alphawolf... I don't really know if this is a bug, or even an important discrepancy... plus, I haven't seen this error on my sites. In fact, when I go to an edit page and hover over the media buttons the tip pops up just fine with no complaints from FireBug; still, this issue may only manifest when certain other JavaScript libraries or plugins are loaded... or when someone's plugin is attempting to call the tTips function for its own purpose.

    The code in common.js which defines the tTips function doesn't precisely match the recommended aliasing method in the link I posted above.

    common.js line 43:

    }(jQuery));

    the recommended aliasing method from the jQuery team:

    })(jQuery);

    Try moving the ")" and see if that corrects the issue (without breaking anything, of course). If so, please post something here... and if you can, file a WordPress bug report.

  10. line47
    Member
    Posted 5 years ago #

    I'm having an issue getting a jquery plugin to work.
    I have tried replacing the $ with jquery in all the javascript files without any luck.

    Here is the page I'm trying to get working...
    http://www.line47.com/discography/

    any help would be greatly appreciated.
    Thanks!
    Scott

  11. line47
    Member
    Posted 5 years ago #

    it's making it though all the scripts but the last it's getting stalled on

    $panels is null on line 13 of slider.js...
    any ideas?

  12. Alphawolf
    Member
    Posted 5 years ago #

    Could be a spelling mistake of yours, but you have to use jQuery, not jquery.

    ps. Nice beard, dude. ;-)

  13. dushyant_su
    Member
    Posted 5 years ago #

    Thanx to this forum,I have solved my problem over here. :)

Topic Closed

This topic has been closed to new replies.

About this Topic