Hi,

Just reuse the same handler for multiple events:

    function handler(event) { /* ... */ }

    element
        .observe('change', handler)
        .observe('paste', handler);

If you need to bind, do that first so you're not creating unnecessary
extra functions:

    var Thingy = Class.create((function() {

        function handler(event) { /* ... */ }

        function hookUsUp(element) {
            var boundHandler = handler.bind(this);
            element
                .observe('change', boundHandler)
                .observe('paste', boundHandler);
        }

        return {hookUsUp: hookUsUp};
    })());

HTH,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com

On Dec 17, 2:03 pm, buda <www...@pochta.ru> wrote:
> What is the best way to attach one observer to many events
> for examle: I need to attach an observer to input element to validate
> input value for 'change' and 'paste' events

--

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 prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.


Reply via email to