.live() is not a function error

Created on 27 June 2014, about 10 years ago
Updated 4 July 2023, 12 months ago

I get this error on my console.

Uncaught TypeError: undefined is not a function

www.mysite.com/sites/all/modules/comment_goodness/comment_goodness.js?n7uccm:5

in firebug it says $(...).live is not a function

I'm using jQuery_update with jQuery 1.10.

I'm near to my production deadline, should I try the dev release?

🐛 Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

🇹🇷Turkey RgnYLDZ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Adjusted patch #16 for 7.x-1.4

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +    // Compatibility for Drupal 7 core (jQuery 1.4.4) and later versions. The
    +    // live() function was removed in jQuery 1.9, but on() was only added in
    +    // 1.6.
    +    var elements = $('form.comment-form div.field-name-comment-body div.text-format-wrapper iframe:not(.cgprocessed)');
    +    // jQuery >= 1.6 can use this ...
    +    if (typeof elements.on === 'function') {
    +      $('form.comment-form div.field-name-comment-body div.text-format-wrapper').on('mouseover focus', 'iframe:not(.cgprocessed)', null, function() {
    +        Drupal.behaviors.comment_goodness.handleEditors($(this));
    +      })
    +    }
    +    // jQuery < 1.6
    +    else if (typeof elements.live === 'function') {
    +      elements.live('mouseover focus', function () {
    +        Drupal.behaviors.comment_goodness.handleEditors($(this));
           });
    +    }
    +  },

    Since Drupal 7 uses jQuery 1.4.4 (< 1.6), the code should first check elements.live is a function, then check elements.on is a function, which is exactly the opposite of what the patch does.

Production build 0.69.0 2024