There's no reason you can't include some prototype extensions where you need
them - not the library, just discrete functions.  Put this in a script file:

//returns -1 if not found
if (!Array.prototype.indexOf) {
        Array.prototype.indexOf = function(val, fromIndex) {
                if (typeof(fromIndex) != 'number') fromIndex = 0;
                for (var index = fromIndex,len = this.length; index < len; 
index++)
                        if (this[index] == val) return index;
                return -1;
        }
}



Rigent wrote:
> 
> I was using prototype in the past and I had written a function that
> involved searching an array for a value passed to the function. I used
> this code:
> 
> if(addArray.indexOf(addvalue) == -1) {
>               addArray[addArray.length] = addvalue
>       } else {
>               return false;
>       }
> 
> Which just looks for a value in an array using indexOf and if it's not
> present it adds the value to the end of the array.
> 
> This works fine in IE and Moz browsers when I was using prototype but now
> I've switched to JQuery this has stopped working in IE.
> 
> Can anyone help me understand why? I've isolated this part of the function
> as what is failing, so there's something about using indexOf with an array
> and the JQuery library that's tripping IE up.
> 
> Any help gratefully received, cheers.
> 

-- 
View this message in context: 
http://www.nabble.com/Why-is-this-not-working-in-JQuery--%28Array.indexOf%29-tf3410614.html#a9507241
Sent from the JQuery mailing list archive at Nabble.com.


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to