Hi, On Oct 11, 3:13 pm, "Miguel Beltran R." <[email protected]> wrote: > Using prototype 1.7 I try to figure what is better, the new ON method or > OBSERVE method but the only thing I found is that ON is better if you wish > use an CSS selector and/or stopObserve > > am I correct? or observe is going to be deprecated?
`on` is just like `observe` if you don't pass it a filtering selector (except that it's more indirect; it eventually ends up calling `observe` under the covers), but I can't imagine `observe` is going to be deprecated. Both have mechanisms for stopping event handlers. With `on` you stop it by calling `stop` on the `EventHandler` object it returns to you; with `observe` you call `stopObserving` with the same arguments you gave `observe` (or fewer, if you want to have a broader effect). The claim is that `on` is useful because you don't have to remember the event handler function if you need to stop it later, but since you have to remember the `EventHandler` instance `on` returns to you, I'm not seeing any net benefit in that sense. `on`'s real use is event delegation IMHO. -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
