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 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?
Comments
Comment #1
RgnYLDZ CreditAttribution: RgnYLDZ commentedI found out that .live() method is deprecated in jQuery 1.7.
Changin
.live()
with.on()
in comment_goodness.js solved my problem.I wrote this in case someone else get this error. But I don't know if it affects something else in the module.
Comment #2
RgnYLDZ CreditAttribution: RgnYLDZ commentedComment #3
RgnYLDZ CreditAttribution: RgnYLDZ commentedComment #4
formatC'vt CreditAttribution: formatC'vt commentedconfirm
Comment #5
formatC'vt CreditAttribution: formatC'vt commentedComment #6
david_garcia CreditAttribution: david_garcia commentedWorks!!
Comment #7
formatC'vt CreditAttribution: formatC'vt commentedyes, works, but maintainers not works
Comment #9
jessebeach CreditAttribution: jessebeach commentedThanks formatC'vt, RgnYLDZ and david_garcia!
Comment #10
jessebeach CreditAttribution: jessebeach commentedSorry, reverted then reapplied. Forgot the --author flag.
2ea0f5e..66f4827
Comment #12
Alan Evans CreditAttribution: Alan Evans commentedUnfortunately, this patch causes an error similar to the one it intends to fix when using a bare Drupal 7 (jQuery 1.4.4).
Options:
Comment #13
Alan Evans CreditAttribution: Alan Evans commentedSimplest (cop-out) solution seems to be to support both for now. I have a working solution tested on D7 core only. Will re-test now with jquery_update 1.7+
Comment #14
formatC'vt CreditAttribution: formatC'vt commentedi create a patch for both, but i little confused, why we need this javascript code? for doing what?
Comment #15
formatC'vt CreditAttribution: formatC'vt commentedi found why we need #1777802: Disable submit actions while the comment body is empty.
Anyway, my patch needs review =)
Comment #16
Alan Evans CreditAttribution: Alan Evans commentedTested
- WYSIWYG comment area with jQuery 1.10 OK
- WYSIWYG comment area with jQuery 1.4 OK
- plain comment area with jQuery 1.4 OK
- plain comment area with jQuery 1.10 OK
- minimal testing on 1.5, 1.7 , 1.8 and 1.9 also seems ok
Will need a review/independent testing still.
Comment #17
Alan Evans CreditAttribution: Alan Evans commentedGah ... just realised we were working on the same thing.
Comment #18
formatC'vt CreditAttribution: formatC'vt commentedYour patch tested more deeply than mine =)
why you doesn't use
elements
variable for jQuery >= 1.6?Comment #19
Alan Evans CreditAttribution: Alan Evans commented@formatC'vt : So, I had to make a couple of assumptions in trying to work out what this code was doing, as there are no useful comments in it. It seemed to me that the only possible thing it could be doing is handling WYSIWYG areas (because of the iframe reference on comment bodies), and I'm increasingly convinced that this is the case, following a bit of testing.
What I'm assuming is that the #states handling of disabling submit buttons doesn't work with WYSIWYGs, so this code was added to handle those. Further, if you try to attach the handling code directly in Drupal behaviors, the handler will fail to attach because the iframe is not yet present in the DOM. So I'm thinking at this point, the author of this code found a way to attach the event just a little later - by adding the mouseover handler to do the attaching. The assumption is that the user always has to click into the comment textarea before using it, and so the handler gets attached at that point. What the final handler seems to do is trigger a keyup() event in the underlying textarea whenever there is an edit in the WYSIWYG editor.
There is a flaw in the original code also in that it assumes you're navigating to the textarea using a mouse, so I'm adding "focus" to the handled events also to cover this.
Comment #20
Alan Evans CreditAttribution: Alan Evans commentedThe reason for not using elements in >= 1.6 is that I need a slightly different selector to get on() to work correctly there - the iframe is not part of that first selector, because the iframe is not yet present in the DOM when that executes. However, the on() syntax allows you to filter down more specifically to the iframe at the point where the mouseover handler is invoked.
If I use the full selector (what's stored in the elements var), then I'll fail to attach the handler, as the iframe doesn't exist at this point of code execution.
There may still be a nicer way of writing this bit of code though.
Comment #21
apadernoThe patch in comment #16 fixes the issue.
Comment #22
apadernoSince Drupal 7 uses jQuery 1.4.4, the code should first verify
live()
exists.Comment #23
Ursegol CreditAttribution: Ursegol at werk21 commentedAdjusted patch #16 for 7.x-1.4
Comment #24
apadernoSince Drupal 7 uses jQuery 1.4.4 (< 1.6), the code should first check
elements.live
is a function, then checkelements.on
is a function, which is exactly the opposite of what the patch does.