[development] behaviors context
Matt Farina
matt at mattfarina.com
Mon Jun 1 03:41:37 UTC 2009
> The problem occurs only when you assume the context is passing
> sufficient information for your behavior. The context may in fact be
> providing less information than you need, and you are at the liberty
> of whatever called attachBehavior() in the first place (which may not
> be something in core -- there's no way to tell). Consequently, it's
> better to rely on the document itself, not just the context.
Sometimes you can't just rely on the document. For an example see the
popups module. It attaches the behaviors to the body of the popup
window. If a popup is built from an AHAH callback you wouldn't want to
reapply the behaviors to the entire document for a popup that's just
part of it. You'd want to apply it to just the new area.
If someone misuses attachBehaviors() should the behaviors be required
to deal with that? They can't foresee everything and there are times
where you want to attach behaviors to something other than the
document. If they misuse attachBehaviors that would be a bug in their
code.
More information about the development
mailing list