[development] behaviors context
matt at aleph-null.tv
Fri May 29 17:46:17 UTC 2009
As far as the context goes, yes -- you are at the mercy of whatever
called Drupal.attachBehaviors(). So it's not all that reliable.
Typically, the whole CSS :not() pseudo-class combined with a
'processed-' class is used to help you find segments that have not
been processed already. There are ample examples of this inside of
Drupal's JS libraries.
On Fri, May 29, 2009 at 12:36 PM, David Cohen <drupal at dave-cohen.com> wrote:
> 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
> 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?
> added content. Does anyone have a snippet of code which returns this,
> given a context?
> Thanks, -Dave
More information about the development