0

What might cause Firefox to tell me $ is not defined, but using 'jQuery' works as expected.

I'm on Wordpress 3.4 and Wordpress comes packaged with jQuery. Is it something specific to Wordpress?

3
  • Would a moderator care to tell me why my comment was deleted? Commented Nov 6, 2012 at 19:58
  • @MatthewBlancarte Huh? I have no idea what your deleted comment was. I posted mine for Jim, independently. Commented Nov 6, 2012 at 22:07
  • @Blazemonger Lol my apologies. I left the same "accept your previous answers" comment and mine was deleted by some random admin. Commented Nov 6, 2012 at 22:18

2 Answers 2

8

jQuery.noConflict() has been called. To resolve this with a minimum amount of code change do this.

Before:

$("your").code(function () {
  $("that").uses($.all("over").the("place"));
});

After:

(function ($) {
  $("your").code(function () {
    $("that").uses($.all("over").the("place"));
  });
})(jQuery);
Sign up to request clarification or add additional context in comments.

2 Comments

Do you ever get the feeling that your computer is... talking to you?
@Blazemonger No, because there is very probably other code that relies on $ not being jQuery (otherwise there'd be no reason to use noConflict() in the first place). Your suggestion would fix one bit of code and break the other.
6

jQuery works in noConflict mode inside wordpress as the docs state: http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_wrappers

1 Comment

Wow. Thanks for that useful bit of info!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.