Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I faced this error while using jQuery 1.10.
This is due to the method live which has been marked as deprecated since jQuery 1.7 and removed in 1.9.
We are now suppose to use on which is backward compatible until 1.7
see jQuery live doc
Comments
Comment #1
theo_ CreditAttribution: theo_ commentedHere is a tiny patch to replace live with on method
Comment #2
dragon658 CreditAttribution: dragon658 commentedSubscribe. (I also have this problem)
Comment #3
srobert72 CreditAttribution: srobert72 commentedComment #4
mglamanHas patch, marking needs review.
Comment #5
mwilliams77 CreditAttribution: mwilliams77 commentedHere is an updated patch, replacing "live" with "on"
Comment #6
BenR CreditAttribution: BenR at Studio Matris commentedWorked for me. #2159009: Uncaught TypeError: Object has no method 'live' commerce_add_to_cart_confirmation.js:9 has very similar patch. This issue is older and I closed the other one.
Comment #7
mglamanDrupal 7 includes jQuery 1.4.4 and jQuery UI 1.8.7. The .on method was added in 1.7.
Comment #8
BenR CreditAttribution: BenR at Studio Matris commentedSorry, missed that. Seems like we will have to use .delegate.
Comment #9
slashrsm CreditAttribution: slashrsm for Studio Matris commentedMajority of sites use versions of jQuery that are newer than those mentioned in #7. .on() seem a good solution as it does the job and is widely supported across different versions.
Comment #10
mglamanI generally don't use jquery_update in my sites. I'm just saying we need a stub, at least. One that checks if the newer function exists.
Comment #11
betarobot CreditAttribution: betarobot commented#8 worked fine for me too with Bootstrap based theme (which requires jQ update).
Comment #12
GoZ CreditAttribution: GoZ as a volunteer commented#8 Works fine for me too with jquery update and jquery 1.10.
We should use each methods depending of jquery version. So people doesn't using jquery_update will use live() (available for Drupal7 included jquery) and on() will be used for people with jquery >= 1.9
Comment #13
BenR CreditAttribution: BenR at Studio Matris commenteddelegate() (used in #8) was added in 1.4.2 and works for both.
Comment #14
gsbc CreditAttribution: gsbc as a volunteer commentedThere was a similar issue with Kickstart ( #2106687: Commerce search error with newer jquery versions (above 1.9)) and it was decided that it was better to use bind because while it just calls on for newer versions, it's also compatible with older versions, so it works out of the box whether jquery_update is used or not.
Here's a suggested patch using bind.
Comment #15
gsbc CreditAttribution: gsbc as a volunteer commentedComment #16
dimmech CreditAttribution: dimmech commentedPatch in #14 worked fine... using jQuery update and version 1.10.
Comment #17
deggertsen CreditAttribution: deggertsen commentedWorks great.
Comment #19
deggertsen CreditAttribution: deggertsen commentedCommitted to dev. Please comment if there are any issues.