So I'm trying to setup the keyup event for my form inputs like this:

        this.MSOFindForm.getInputs('text').each(function(input) {
            Event.observe(input, 'keyup', this.Find.bindAsEventListener
(this));
        });


The above is part of the initialize event for the class MSOFindForm.
The MSOFindForm has a Find method.  I am getting an error though,
which says that this.Find is not defined.  Uggg, I'm confused.

Karl..

On Apr 9, 4:17 pm, Ryan Gahl <[email protected]> wrote:
> OK
>
> Someone might want to jump in here, as I'm not 100% of the behavior of the
> passed in event obj.
>
> Basically I think you can just do the following:
>
> var func = function() { this.Find(input, objEvent, false); }.bind(this);
>
> > //get rid of the func = func.bind(this) line and just bind inline
>
>  since the variables input and objEvent are closed over that should be all
> you need to do. The caveat to that is if the objEvent reference changes with
> other events that happen after you set up the timer, and that's where
> someone like kangax can probably jump in and say yea or nay immediately (of
> course you can just try it).
>
> If that doesn't work, then you might want to create the timer in such a way
> that it passes just the keycode part of the event object (which is all you
> seem to need). I can see that looking kind of like this:
>
> Find: function(input, objEvent, useractive) {
>
>
>
> >    var keycode = objEvent.keyCode;
> >    this.__doFind(input, keycode, useractive);
> > },
> > __doFind: function(input, keycode, useractive) {
> >     this.flgUserActive = useractive;
>
> >    // keycode ignore list
> >    if (this.aKeyCodeIgnoreList.include(keycode))
> >        return false;
>
> >    // ajax spinning (no action)
> >    if (this.flgAjaxActive)
> >        return;
>
> >    // user typing (no immediate action, set timer)
> >    if (this.flgUserActive) {
> >        this.flgUserActive = false;
>
> >        var form = this.MSOFindLayer.select('form')[0];
>
> >        //test 2 leters in 1st word for up to two words (trailing space is
> > bad)
> >        if (!($(input).value.match(/^[a-zA-Z]{2,40}(.[a-zA-Z]{1,40})?$/im)))
> >            return;
>
> >        if (this.timer != null)
> >            clearTimeout(this.timer);
>
> >        var func = function() { this.__doFind(input, keycode, false);
> > }.bind(this);
> >        this.timer = setTimeout(func, 300);
>
> >        return;
> >    }
>
> >    // if we made it this far, call the find
> >    __find(input);
> > }
>
> Ultimately, though, you should be attaching your listeners via javacript,
> which in this case will probably make life a little easier.
>
> Ryan Gahl
> CEO
> Nth Penguin, LLChttp://www.nthpenguin.com
> --
> Inquire: 1-920-574-2218
> Blog:http://www.someElement.com
> LinkedIn Profile:http://www.linkedin.com/in/ryangahl
>
> On Thu, Apr 9, 2009 at 4:55 PM, kstubs <[email protected]> wrote:
> > var func = function(input, objEvent) { this.Find(input,
> > objEvent, false); };
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to