On Jun 4, 2009, at 8:36 PM, Luisgo wrote:

> 1. Is there a better way to handle callback definition? See lines
> 7-11.

You've got the right idea here. I'd use `Prototype.emptyFunction`  
instead because there's no reason to define more than one empty  
function, but this is of negligible importance.

> 2. Is there a better way of referring to "body"? See line 33.

`$(document.body)` would be more concise. Works in all browsers I'm  
aware of.

> 3. Is there a better way of "injecting" callbacks into functions so I
> don't have to clutter methods like "on" and "off"? See lines 81, 91,
> 98, 108.

You seem reluctant to keep them on the `settings` object — why? Only  
difference is that you'd call `this.settings.onBeforeOpen()` instead.  
Scope would be preserved.

A _different_ approach to callbacks would be to use custom events — to  
fire "modal:opened:before" and "modal:opened:after" (etc.) — but there  
are pros and cons for each.

> 4. Is there a way to use prototype classes that take an element as
> extensions to such element? Meaning, I would like to be able apply a
> "click" observer to the instance of the class directly. Something
> like:
>  `modal.observe("click", someHandler)`
> and have that passed to the element to which the class is applied to.
> In the class: `this.element` or in this example `modal.element`

No, but if you wanted that sort of thing, you could write your own  
`observe` method which passed all its arguments to  

You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to