One more thing: I'm using the autocomplete on a project where Ext is
also installed, and there are no compability issues.

Jörn

On Wed, Jul 2, 2008 at 10:24 AM, Jörn Zaefferer
<[EMAIL PROTECTED]> wrote:
> Okay, thanks for the clarification. Though I still can't reproduce the
> problem your describe - the autocomplete iterates over the data array
> with an index-based for loop, and anything added to the array
> prototype is ignored.
>
> Can you provide a testpage where the issue actually occurs in
> combination to the autocomplete plugin?
>
> Btw., Firebug displays the array in different ways, but the
> letsBreakStuff property is there in both cases.
>
> Jörn
>
> On Tue, Jul 1, 2008 at 4:59 PM, Bramus! <[EMAIL PROTECTED]> wrote:
>>
>> Hi Jörn,
>>
>> exactly, the function gets iterated too and is considered as the last
>> element of the array. When passed on to autocomplete, it will break as
>> s.toLowerCase() is invalid when s isn't a string. Therefore; my patch
>> over at http://dev.jquery.com/attachment/ticket/3080/jquery.autocomplete.diff
>> (2 little additions to make autocomplete even more idiotproof than it
>> already is ;))
>>
>> On a sidenote: The strangest part of it all is that the letsBreakStuff
>> function doesn't get applied on "normal" arrays (see the correct array
>> in the example mentioned earlier) but only to arrays created as an
>> element of an Object (or so it seems in the wrong array mentioned
>> earlier).
>>
>> Regards,
>> Bram.
>>
>> On Jul 1, 3:47 pm, "Jörn Zaefferer" <[EMAIL PROTECTED]>
>> wrote:
>>> Okay, so the issue is that letsBreakStuff gets iterated together with
>>> the rest of the array, while it should be ignored, as it doesn't have
>>> a numerical index, right?
>>>
>>> How does that relate to your patch?
>>>
>>> Jörn
>>>
>>> On Tue, Jul 1, 2008 at 11:36 AM, Bramus! <[EMAIL PROTECTED]> wrote:
>>>
>>> > Hi Jörn,
>>>
>>> > The problem in fact is Ext Related, yet can be reproduced without Ext:
>>> > any library that expands the Array prototype with a function can be
>>> > the wrongdoer.
>>>
>>> > Create a new blank document (nothing needs to be in it), open up
>>> > firebug and paste in the code below:
>>>
>>> > Array.prototype.letsBreakStuff = function(){return this};
>>> > correct = [
>>> >    "baa",
>>> >    "bah!",
>>> >    "bar",
>>> >    "bar!",
>>> >    "beblog",
>>> >    "bezar",
>>> >    "blog",
>>> >    "blub",
>>> >    "blub!",
>>> >    "boo",
>>> >    "bramus"
>>> > ];
>>>
>>> > As you can see this in fact does work correct.
>>>
>>> > However, I'm a great JSON-addict, and my autocompletion data - just as
>>> > any other call - is returned in the Object Literal Notation (and then
>>> > run through a custom parse function to get an autocomplete compatible
>>> > array).
>>>
>>> > Now, open up Firebug again and paste in this code:
>>>
>>> > Array.prototype.letsBreakStuff = function(){return this};
>>> > wrong = { "data":[
>>> >        "baa",
>>> >        "bah!",
>>> >        "bar",
>>> >        "bar!",
>>> >        "beblog",
>>> >        "bezar",
>>> >        "blog",
>>> >        "blub",
>>> >        "blub!",
>>> >        "boo",
>>> >        "bramus"
>>> >    ]
>>> > }
>>>
>>> > Check wrong.data, you'll see that the last item is the letsBreakStuff
>>> > function.
>>>
>>> > To make it all complete: the reason I named Ext is that I got the
>>> > remove function as last item on wrong.data ... which is added by Ext:
>>> > Ext.applyIf(Array.prototype,{indexOf:function(C){for(var
>>> > B=0,A=this.length;B<A;B++){if(this[B]==C){return B}}return
>>> > -1},remove:function(B){var A=this.indexOf(B);if(A!=-1){this.splice(A,
>>> > 1)}return this}});
>>>
>>> > Hope you now see why exactly I suggested that little patch ;)
>>>
>>> > Regards,
>>> > Bramus!
>>>
>>> > On Jun 24, 3:57 pm, "Jörn Zaefferer" <[EMAIL PROTECTED]>
>>> > wrote:
>>> >> I don't quite the how the issue is related to ExtJS. It sounds like
>>> >> you pass functions instead of strings to the autocomplete plugin,
>>> >> which is the actual issue here. Could you upload a testpage and post
>>> >> the URL here?
>>>
>>> >> Jörn
>>>
>>> >> On Tue, Jun 24, 2008 at 1:03 PM, Bramus! <[EMAIL PROTECTED]> wrote:
>>>
>>> >> > Filed a ticket on dev.jquery including a .diff 
>>> >> > file:http://dev.jquery.com/ticket/3080
>>> >> > ;-)
>>>
>>> >> > Regards,
>>> >> > B!
>>>
>>> >> > PS: [autocomplete] prefix seems to be cut off subject?
>>>
>>> >> > On Jun 24, 11:15 am, "Bramus!" <[EMAIL PROTECTED]> wrote:
>>> >> >> Hi Jörn et all here at the list,
>>>
>>> >> >> I'm using the autocomplete plugin in a project I'm working on and I
>>> >> >> must say: it works great!. However: one part of the project uses ExtJS
>>> >> >> (their tree component is great) and that's where things go wrong.
>>> >> >> Problem is that somewhere in ExtJS they extend Object with a remove()
>>> >> >> function, breaking jQuery.autocomplete.
>>>
>>> >> >> After a little quest I found that - quite obviously - autocomplete
>>> >> >> breaks on string manipulations (Function.toLowerCase() doesn't really
>>> >> >> exist ;)) and has a minor issue when displaying the items whenever
>>> >> >> some library has extended Object.
>>>
>>> >> >> Here below are the 2 minor changes I implemented in order to make
>>> >> >> things work "just fine" again. Could you tuck 'm into the release as I
>>> >> >> can't commit any changes to the trunk.
>>>
>>> >> >> Change #1: Display issue: $.Autocompleter.Select, function fillList():
>>> >> >> replace:
>>> >> >> if (!data[i])
>>> >> >> with:
>>> >> >> if (!data[i] || (data[i].value.constructor === Function))
>>>
>>> >> >> Change #2: Selection issue: $.Autocompleter.Cache, function
>>> >> >> matchSubset()
>>> >> >> at line#1 of this function (directly after the opening { ) add:
>>> >> >> if (s.constructor === Function) return false;
>>>
>>> >> >> Regards,
>>> >> >> Bramus!
>>
>

Reply via email to