I implemented my own autocompleter a long time ago. I couldn't release it 
because my company technically owns it now.

This is the way I did it:

        Set Up a Timer that start when the textField takes input (onFocus)
        Save the timer object and destroy it when the user leaves the field 
(onBlur)
        The timer should call a function that checks the user's text.
        If the text is longer than the last known stored value OR 
it is different than the last stored value attempt to suggest
        

-Andrew Martinez

 -----Original Message-----
From:   [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]  On Behalf Of Mark McCray
Sent:   Tuesday, May 23, 2006 2:55 PM
To:     [email protected]
Subject:        Re: [Rails-spinoffs] throttling...

Actually,
here's what i'm trying to do:

I want the user to be able to type in some text in an input field and  
i only want the ajax request to happen after the user has stopped  
typing for 1 or two seconds. Kind of like how google suggest or  
autocompleter works. I can't use the ajax autocompleter because we  
have a specific requirement that makes the autocompleter not work for  
us.

Thanks,
mark

On May 23, 2006, at 2:37 PM, Martinez, Andrew wrote:

> HTML was stripped: go here: http://www.sergiopereira.com/articles/ 
> prototype.js.html#Ajax.options
>
> -Andrew Martinez
>
>  -----Original Message-----
> From:         [EMAIL PROTECTED] [mailto:rails- 
> [EMAIL PROTECTED]  On Behalf Of Martinez, Andrew
> Sent: Tuesday, May 23, 2006 2:32 PM
> To:   [email protected]
> Subject:      RE: [Rails-spinoffs] throttling...
>
> In the options argument you have the following options (http:// 
> www.sergiopereira.com/articles/prototype.js.html ) and you will  
> want to use Ajax.PeriodicalUpdater w/ the last options:
>
> The options argument object
> An important part of the AJAX operations is the options argument.  
> There's no options class per se. Any object can be passed, as long  
> as it has the expected properties. It is common to create anonymous  
> objects just for the AJAX calls.
> Property      Type    Default Description
> method        String  'post'  Method of the HTTP request
> parameters    String  ''      The url-formatted list of values passed to the  
> request
> asynchronous  Boolean true    Indicates if the AJAX call will be made  
> asynchronously
> postBody      String  undefined       Content passed to in the request's body 
>  
> in case of a HTTP POST
> requestHeaders        Array   undefined       List of HTTP headers to be 
> passed  
> with the request. This list must have an even number of items, any  
> odd item is the name of a custom header, and the following even  
> item is the string value of that header. Example:['my-header1',  
> 'this is the value', 'my-other-header', 'another value']
> onXXXXXXXX    Function(XMLHttpRequest, Object)        undefined       Custom  
> function to be called when the respective event/status is reached  
> during the AJAX call. Example var myOpts = {onComplete:  
> showResponse, onLoaded: registerLoaded};. The function used will  
> receive one argument, containing the XMLHttpRequest object that is  
> carrying the AJAX operation and another argument containing the  
> evaluated X-JSON response HTTP header.
> onSuccess     Function(XMLHttpRequest, Object)        undefined       Custom  
> function to be called when the AJAX call completes successfully.  
> The function used will receive one argument, containing the  
> XMLHttpRequest object that is carrying the AJAX operation and  
> another argument containing the evaluated X-JSON response HTTP header.
> onFailure     Function(XMLHttpRequest, Object)        undefined       Custom  
> function to be called when the AJAX call completes with error. The  
> function used will receive one argument, containing the  
> XMLHttpRequest object that is carrying the AJAX operation and  
> another argument containing the evaluated X-JSON response HTTP header.
> onException   Function(Ajax.Request, exception)       undefined       Custom  
> function to be called when an exceptional condition happens on the  
> client side of the AJAX call, like an invalid response or invalid  
> arguments. The function used will receive two arguments, containing  
> the Ajax.Request object that wraps the AJAX operation and the  
> exception object.
> insertion     an Insertion class      undefined       A class that will 
> determine  
> how the new content will be inserted. It can be Insertion.Before,  
> Insertion.Top, Insertion.Bottom, or Insertion.After. Applies only  
> to Ajax.Updater objects.
> evalScripts   Boolean undefined, false        Determines if script blocks  
> will be evaluated when the response arrives. Applies only to  
> Ajax.Updater objects.
> decay Number  undefined, 1    Determines the progressive slowdown in a  
> Ajax.PeriodicalUpdater object refresh rate when the received  
> response is the same as the last one. For example, if you use 2,  
> after one of the refreshes produces the same result as the previous  
> one, the object will wait twice as much time for the next refresh.  
> If it repeats again, the object will wait four times as much, and  
> so on. Leave it undefined or use 1 to avoid the slowdown.
> frequency     Number  undefined, 2    Interval (not frequency) between  
> refreshes, in seconds. Applies only to Ajax.PeriodicalUpdater objects.
>
>
> var myUpdater =  new Ajax.PeriodicalUpdater( $('itemId'), url,  
> {frequency:1} );
>
> -Andrew Martinez
>
>  -----Original Message-----
> From:         [EMAIL PROTECTED] [mailto:rails- 
> [EMAIL PROTECTED]  On Behalf Of Mark McCray
> Sent: Tuesday, May 23, 2006 2:20 PM
> To:   [email protected]
> Subject:      [Rails-spinoffs] throttling...
>
> Is there a way to throttle the firing of updater requests easily with
> Prototype?
> Thanks,
> mark
>
>
> _______________________________________________
> Rails-spinoffs mailing list
> [email protected]
> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
> _______________________________________________
> Rails-spinoffs mailing list
> [email protected]
> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
> _______________________________________________
> Rails-spinoffs mailing list
> [email protected]
> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
>

_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to