Great, thanks! By the way, wondering if my understanding of setting
up event handlers to begin with is confusing things since I am
invoking the method as an HTML onkeyup event, rather than setting up
the event is javascript code (in my class initialize method) and using
the observe methods.
So, I'll include the HTML snip, and complete FIND code which is a
method of my QuickFind class. Again, the idea is this: user enter
text into an input field, but the Find method would only call the
internal __find() method after a delay 1/300 of a second.
HTML SNIP:
<div class="input">
<input name="event_name" type="text" onkeyup="_mf.Find
(this, event, true);" title="Event"/>
<span>Enter an Event Name - Start Typing!</span>
</div>
Class Instantiation Snip:
_mf = new QFind('MSO_FIND');
Find() Method:
Find: function(input, objEvent, useractive) {
var keycode = objEvent.keyCode;
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(input, objEvent) { this.Find(input,
objEvent, false); };
func = func.bind(this);
this.timer = setTimeout(func, 300);
return;
}
// if we made it this far, call the find
__find(input);
}
});
On Apr 9, 2:39 pm, Ryan Gahl <[email protected]> wrote:
> Let's back up... give me the whole blob of code... sorry I thought func was
> being executed AS an element event handler, but it's clearly not. If you
> paste in the rest of the (relevant) code as it sits now I can help you fix
> it up.
>
> 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:26 PM, kstubs <[email protected]> wrote:
>
> > Well, I've tried a couple of different things, not the
> > bindAsEventListener() yet.
> > So thinking there might be a naming conflict, I opted to change the
> > event parameter name to objEvent. So now I have:
>
> > Find: function(input, objEvent, useractive) {
> > var keycode = objEvent.keyCode;
>
> > and my timer code looks like:
>
> > var func = function(input, objEvent) { this.Find(input,
> > objEvent, false); };
> > func = func.bind(this);
> > this.timer = setTimeout(func, 300);
>
> > I'm getting the exact same error (notice I add input to the function
> > statement, but I have tried this with and without the additional input
> > parameter).
>
> > > Note, I believe .bind() automagically passes the event object along to
> > the
> > > bound function these days (you just have to include it as a named param).
> > If
>
> > What does that mean exactly?
>
> > Thanks, Karl..
>
> > On Apr 9, 2:04 pm, Ryan Gahl <[email protected]> wrote:
> > > Try something like this:
>
> > > var func = function(event) { this.Find(input, event, false); }; //
> > notice
>
> > > > I added the named argument "event" to the func signature
>
> > > Note, I believe .bind() automagically passes the event object along to
> > the
> > > bound function these days (you just have to include it as a named param).
> > If
> > > not, try the legacy .bindAsEventListener() instead of .bind().
>
> > > 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 3:59 PM, kstubs <[email protected]> wrote:
> > > > var func = function() { this.Find(input, event, false); };
> > > > func = func.bind(this);
> > > > this.timer = setTimeout(func, 300);
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---