$ is not a function
is a common error message newbies encounter when trying to use JQuery in Drupal 7.
The explanation is that the usage of $ is disabled in Drupal to avoid conflicts with other libraries. But which other library is using $?
$ is not a function
is a common error message newbies encounter when trying to use JQuery in Drupal 7.
The explanation is that the usage of $ is disabled in Drupal to avoid conflicts with other libraries. But which other library is using $?
At least two major ones:
It is probably because using one char for most commonly used function saves a lot of time. And due to some restrictions for characters in variable name in JavaScript there are actually two candidates for such one-char names: $
and _
(_
is used often for eg. gettext functions or throw-away variables). Thus I would rather expect that if some framework has some shortcut function with one char name, it is probably $
.
One of the common problems is several different versions of JQuery itself, though I'm not sure that is the reason in Drupal. Another possibility is Mootools
zepto also uses $, and is a lightweight alternative to jQuery:
In addition, it matches most of the jQuery API.