4 users online. Create an account or sign in to join them.Users

Search

While trying to use new, already included, jQuery-lib I am getting errormessages saying “$ is not a function”. Do I have to use a special variable for jQuery (I remember discussions about Prototype and jQuery both using $)?

jQuery uses $ by default, but because extension developers can include Prototype (and others) if they wish, jQuery is included using the “no conflict” method.

This means you need to use jQuery() rather than $().

To make this less painful and to use the $ syntax still, you can wrap your JS in a self-executing anonymous function, passing $ by reference:

See how Scott does it in admin.js. I use a similar method here:

http://github.com/nickdunn/uploadify/blob/cce714e14b62d16b36c773122b204ba6cf6746c4/assets/apply.js

That makes things a little more difficult. I am able to call the jQuery-script using

 jQuery("textarea").tabby();

but Tabby itself is using

 setTimeout("$.fn.tabby.pressed.last = null;",0);

wich doesn’t know $ (global scope of setTimeout). Any ideas?

Which is a Tabby bug ;-)

Ok, changing it to

setTimeout("jQuery.fn.tabby.pressed.last = null;",0);

helps. I wrote the developer of Tabby to change that in his official release (I hope jQuery.whatever() works even when “no conflict”-mode is disabled). Thanks for helping out.

I hope jQuery.whatever() works even when “no conflict”-mode is disabled

It will indeed. jQuery is the default function/class name, but it adds $ as a shorthand alias.

noConflict mode is very usewful but a lot of jQuery plugin developers forget people use it and they often reference a global $ which is very frustrating.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.2 or above
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.0 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details