Closed (works as designed)
Project:
Drupal core
Version:
7.x-dev
Component:
javascript
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
17 Mar 2009 at 15:30 UTC
Updated:
28 Apr 2009 at 13:01 UTC
Now that jQuery 1.3 is in drupal core we can take advantage of some new features like jQuery.live(). Let's see if we can replace out custom Drupal.behaviors with jQuerys native jQuery.live() and jQuery.die().
http://docs.jquery.com/Events/live
http://docs.jquery.com/Events/die
Comments
Comment #1
mfer commentedAdding javascript tag
Comment #2
robloachUnsubscribing.
Comment #3
starbow commentedsubscribing
Comment #4
katbailey commentedThis would seem like a sensible move, but what about #360081: Pass Settings Locally to JS Behaviors? If we get rid of the Drupal.attachBehaviors function we'll need to think of another way of passing the settings of new ajax-loaded content.
Comment #5
mfer commented@katbailey Good point on the local settings. That patch is already in core and is just waiting on documentation at this point, too.
I'm not convinced that .live() and .die() are the way for us to go... we need to talk about it and see if it's even possible. We may even be able to pass on stuff to jQuery for the next version.
Though... you can pass in custom variables to http://docs.jquery.com/Events/live. See the examples....
Comment #6
sunGood call. I had a quick look at .live() some weeks ago and identified some hurdles (which I can't remember now) that would not allow us to do this, but - maybe - we can talk to jQuery devs about it.
Comment #7
aaron commentedsubscribe
Comment #8
kkaefer commented"Currently not supported: blur, focus, mouseenter, mouseleave, change, submit"
Comment #9
kkaefer commentedThere are some performance problems with using
.live()on a big scale:.live()doesn’t bind the events to a particular DOM element, but rather attaches them to<body>. If an event occurs, the event bubbles up the DOM tree until<body>and is handled there. jQuery then checks whether the selector matches the original element this event was created for and executes the function if that’s the case. This might be a lot slower in some cases (and a lot faster in other cases, such as when you have a very big number of the same event handlers). Overall, I don’t think we should dropDrupal.behaviorsin favor of.live(). They serve different purposes.Comment #10
mfer commented@kkaefer I agree that we need to keep Drupal.behaviors. There has been a lot of talk about this so I wanted to open up the issue for documented discussion and a central place to test if it's viable.
Comment #11
mfer commentedUnless someone has a reason and a patch to replace Drupal.behaviors with jQuery.live I'm marking this by design. Drupal.behaviors is designed to be different than jQuery.live.