What does one have to do in the code below to allow jQuery to make use of the find() function that I added to the array object (see line #26)?
Is there a namespace clash?
The code is here http://jsbin.com/oluyu6/5/edit
Thanks.
Is there a namespace clash?
The code is here http://jsbin.com/oluyu6/5/edit
Thanks.
Code:
Array.prototype.find = function(searchStr) { // http://www.hunlock.com/blogs/Mastering_Javascript_Arrays#quickIDX39 var returnArray = false; for (i=0; i<this.length; i++) { if (typeof(searchStr) == 'function') { if (searchStr.test(this[i])) { if (!returnArray) { returnArray = []; } returnArray.push(i); } } else { if (this[i]===searchStr) { if (!returnArray) { returnArray = []; } returnArray.push(i); } } } return returnArray; }; function toggleArrowBySelectedVal(option_array, list_id, arrow) { var list=$("#"+list_id); var numselected=$("#"+list_id+" option:selected").length; if ( (numselected==1) && (option_array.find(Number(list.value)))) arrow.disabled=false; else arrow.disabled=true; }
Comment