I tried to assign ['el1', 'el2', 'el3', 'el4', 'el5'] to an array
variable declared as ArrayVariable = New Array();

This worked.

So I tried to use ArrayVariable.push(value); for every value in the
json stucture to assign all the elements to the array.

This did not work.


Finally, since data.constructor.toString() returns "function Array()
{[native code]}" I changed the method of testing for a valid array in
jquery.autocomplete.js on line 463 from

options.data = ((typeof data == "object") && (data.constructor ==
Array)) ? data : null;

to

options.data = ((typeof data == "object") && (data.constructor.toString
().indexOf("function Array()") != -1)) ? data : null;

I gather that testing for an array under all conditions and across all
browsers is not a simple task.

How many more ways can there be to change json data to a valid array
that can be tested using the array object constructor == Array across
all browsers?



On Aug 27, 9:35 pm, RobGMiller <robgmil...@gmail.com> wrote:
> Thanks for the reply James,
>
> Got it fromhttp://www.pengoworks.com/workshop/jquery/autocomplete.htm
> because it will handle the local array as opposed to the ajax call.
>
> By the way. It will work as the example does as follows:
>
>  $("#inputbox").autocompleteArray(['value1','valued','value3'], {
>                  delay: 10,
>                  minChars: 1,
>                  matchSubset: 1,
>                  onItemSelect: selectItem,
>                  onFindValue: findValue,
>                  autoFill: true,
>                  maxItemsToShow: 10
>              });
>
> I just need to know how to put that array in a variable because the
> array has to be created dynamically when the page opens.
>
> On Aug 27, 7:51 pm, James <james.gp....@gmail.com> wrote:
>
>
>
> > Which autocomplete library are you using?
> > This one? ->http://dyve.net/jquery/?autocomplete
>
> > The most popular one currently is by Jörn 
> > Zaffaerer:http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/
>
> > That one doesn't have a "autocompleteArray".
>
> > On Aug 27, 2:40 pm, RobGMiller <robgmil...@gmail.com> wrote:
>
> > > Coded the following in a page :
>
> > > var ArrayVariable = New Array();
> > > $(document).ready(function() {
> > >      $("#inputbox").autocompleteArray(ArrayVariable, {
> > >                 delay: 10,
> > >                 minChars: 1,
> > >                 matchSubset: 1,
> > >                 onItemSelect: selectItem,
> > >                 onFindValue: findValue,
> > >                 autoFill: true,
> > >                 maxItemsToShow: 10
> > >             });
>
> > > });
>
> > > Filling the input box does not present the list of matching array
> > > elements. I believe the array has the wrong structure because it is
> > > not recognized in  jQuery.fn.autocomplete. options.data is set to null
> > > because data.constructor does not return an array.
>
> > > The array is filled by looping through all elements of a json stucture
> > > returned from an ajax call as in ArrayVariable[index] = jsonResponse
> > > [i]. It appears to be a normal array when looking at it with visual
> > > studio.
>
> > > I've also tried to create a string as in var ArrayVariable = ""; and
> > > ArrayVariable = "[ 'elementone', 'elementtwo', 'elementthree']"; but
> > > that was not successfull either.
>
> > > Can someone indicate the correct structure of the array required.

Reply via email to