Currently the plugin is constructed around the two supported
datasources, while needing a lot of refactoring to offer proper
support for other datasources.

As your datasource runs async, an option may be to intercept the
$.ajax method (see http://docs.jquery.com/Types#Proxy_Pattern). Your
proxy would check for a custom option or a certain URL, and if that is
used, delegate the request handling to your existing function,
triggering the success-callback in the same way $.ajax does. Something
like this:

(function() {
  // log all calls to setArray
  var proxied = jQuery.ajax;
  jQuery.ajax = function(options) {
    if (options.autocomplete) {
      handleRequest(options.data, options.success);
    }
    return proxied.apply(this, arguments);
  };
});

Jörn

On Wed, Jun 4, 2008 at 11:35 PM, Tyler <[EMAIL PROTECTED]> wrote:
>
> I have a JavaScript function that makes an Ajax call and returns
> results into a local variable.  I would like to call this function
> from the Autocomplete plugin (http://bassistance.de/jquery-plugins/
> jquery-plugin-autocomplete/) as my Ajax data souce.  I understand that
> Autocomplete can use either a local variable or a URL, but the
> framework I'm using has some built-in Ajax functions to set the value
> of a variable, run a SQL query, and return the result.
>
> I could do this by re-writing autocomplete, but I don't think that's
> the best solution.
>
> So, lets say I have some JavaScript function called getMyData, how
> would I extend Autocomplete such that it calls getMyData instead of a
> URL to get the results?
>
> Thanks,
> Tyler
>

Reply via email to