[jQuery] Re: inArray inst working in my script

2008-02-04 Thread Karl Rudd
inArray doesn't return a boolean, it returns an index and -1 if the
value is not in the array.

jQuery.inArray( value, array )
Determine the index of the first parameter in the Array (-1 if not found).

from: http://docs.jquery.com/Utilities/jQuery.inArray#valuearray

So you need to change:

if ( ! $.inArray(nuevo_estilo[0].href, estilos_href) ) {

To:

if ( $.inArray(nuevo_estilo[0].href, estilos_href) == -1 )

Karl Rudd

On Feb 5, 2008 10:31 AM, Sebastián Würtz [EMAIL PROTECTED] wrote:

 Sebastián Würtz escribió:
 
  jQuery.getCSS = function(url, media, rel, title) {
 estilos_href = new Array();
 $.each( document.styleSheets, function(i, n){
 estilos_href[i] = n.href;
 });
 nuevo_estilo = jQuery(document.createElement('link')).attr({
 href: url,
 media: media || 'screen',
 type: 'text/css',
 title: title || '',
 rel: rel || 'stylesheet'
 });
 
 if ( ! $.inArray(nuevo_estilo[0].href, estilos_href) ) {
 nuevo_estilo.appendTo('head');
 }
  };
 
  what im doing wrong?
 
 pls some hand?



[jQuery] Re: inArray inst working in my script

2008-02-04 Thread Sebastián Würtz


Sebastián Würtz escribió:


jQuery.getCSS = function(url, media, rel, title) {
   estilos_href = new Array();
   $.each( document.styleSheets, function(i, n){
   estilos_href[i] = n.href;
   });
   nuevo_estilo = jQuery(document.createElement('link')).attr({
   href: url,
   media: media || 'screen',
   type: 'text/css',
   title: title || '',
   rel: rel || 'stylesheet'
   });

   if ( ! $.inArray(nuevo_estilo[0].href, estilos_href) ) {
   nuevo_estilo.appendTo('head');
   }
};

what im doing wrong?


pls some hand?