[development] behaviors context
David Cohen
drupal at dave-cohen.com
Fri May 29 17:36:20 UTC 2009
I'm trying to implement a Drupal.behavior. I realize my behavior
function is passed a "context". But it's unclear to me what that
context will be.
If I understand correctly, when the behavior is first invoked, it is
passed document, a variable built into javascript.
Later, when some module's javascript adds content to the page, my
behavior will be invoked again. This time, context could be anything.
The module which added the content can pass whatever. So for example in
ahah.js, Drupal.attachBehaviors() is passed a jquery object representing
the new content. While in modules/views/js/ajax.js,
Drupal.attachBehaviors() is passed a string or id, either of which could
be used in a jquery selector.
Do I have this right?
What I need is the javascript element (not jquery object) that is the
added content. Does anyone have a snippet of code which returns this,
given a context?
Thanks, -Dave
More information about the development
mailing list