[development] Using Drupal.(attach)behaviors instead of .live
Anthony Malkoun
malkouna at yahoo.com.au
Fri Apr 15 02:00:08 UTC 2011
My understanding is that Drupal.behaviours is just like .ready. I don't
understand your distinction between ajax and js, the J in ajax stands
for javascript. But at any rate, if you're doing something on an
element that doesn't exist yet, then that's what .live is for. Just put
that in your js that is in your page on the element you're expecting.
All .live really does is use event bubbling and event delegation to
capture the event on a containing element.
On 6:59 AM, jeff at ayendesigns.com wrote:
> In the case where there will be a popup opening on a page (not sure if
> it will be via ajax or js yet) and I need a function to fire when the
> popup closes, will Drupal.behaviors <http://Drupal.behaviors> act like
> .live in that it will bind the function to the event at the time that
> the selector becomes available (read: the popup eventually exists) ?
> I was thinking perhaps this is where attachbehaviors is supposed to be
> used, but that, I think, implies that I can alter the code that
> creates the popup, and I cannot...I just need to 'hook' into its close
> event.
>
> Jeff
More information about the development
mailing list