[Proto-Scripty] $$ utility method returns href value instead of anchor tag reference

2009-03-20 Thread tkane2000

How come the $$() function returns the value of the href when
selecting an anchor tag instead of the tag itself?  ...I've had mixed
results for this btwn FF and IE6, but it's consistant in the code
below.  Anyone know what I'm doing wrong here or if there's a
workaround?

div id=gallery
div class=thumb
div class=listItem
a href=/asdfasdf/asdfsdf.jhtml 
class=thumbHolderthis is some
text/abr /
a href=/asdfasdf/asdfsdf.jhtml 
class=thumbHolderthis is some
text/abr /
/div
/divbr /
div class=thumb
div class=listItem
a href=/asdfasdf/234234.jhtml 
class=thumbHolderthis is some
text 21/abr /
a href=/asdfasdf/234234.jhtml 
class=thumbHolderthis is some
text 23/abr /
/div
/div
/div

script type=text/javascript
var links = $$('.gallery .thumb .listItem .thumbHolder');
alert(links[0]: + links[0]);
/script

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: $$ utility method returns href value instead of anchor tag reference

2009-03-20 Thread tkane2000

hmm, well, links[0] is returning a string, not the a object, so those
will both return null.

The question is why does this statement:
$$('.gallery .thumb .listItem .thumbHolder');
return the value of href (a string) and not that a object?

Thanks!

On Mar 20, 6:38 am, Richard Quadling rquadl...@googlemail.com wrote:
 Almost certainly you are seeing the results of a toString() method
 kicking in for the objects (or similar).

 Try ...

 alert(links[0]: + links[0].id + ':' + links[0].href);

 Richard Quadling.

 2009/3/20 tkane2000 tkthomp...@gmail.com:





  How come the $$() function returns the value of the href when
  selecting an anchor tag instead of the tag itself?  ...I've had mixed
  results for this btwn FF and IE6, but it's consistant in the code
  below.  Anyone know what I'm doing wrong here or if there's a
  workaround?

  div id=gallery
         div class=thumb
                 div class=listItem
                         a href=/asdfasdf/asdfsdf.jhtml 
  class=thumbHolderthis is some
  text/abr /
                         a href=/asdfasdf/asdfsdf.jhtml 
  class=thumbHolderthis is some
  text/abr /
                 /div
         /divbr /
         div class=thumb
                 div class=listItem
                         a href=/asdfasdf/234234.jhtml 
  class=thumbHolderthis is some
  text 21/abr /
                         a href=/asdfasdf/234234.jhtml 
  class=thumbHolderthis is some
  text 23/abr /
                 /div
         /div
  /div

  script type=text/javascript
         var links = $$('.gallery .thumb .listItem .thumbHolder');
         alert(links[0]: + links[0]);
  /script

 --
 -
 Richard Quadling
 Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498r=213474731
 Standing on the shoulders of some very clever giants!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: $$ utility method returns href value instead of anchor tag reference

2009-03-23 Thread tkane2000

thanks guys, that makes sense.  I hacked around w/ it and found that
the issue I'm running into was based on 2 things:
1. I'm selecting gallery as a class instead of an id (syntax error)
2. I'm running into an issue w/ IE in which I can't overwrite the
onClick attribute.

#2 isn't shown in this example.  ...long story as to why I need to do
this and I'm not sure it's possible really.  ...will start a new
thread.

Thanks Again!

On Mar 23, 7:51 am, Richard Quadling rquadl...@googlemail.com wrote:
 2009/3/21 T.J. Crowder t...@crowdersoftware.com:





  Hi,

  hmm, well, links[0] is returning a string, not the a object...

  No, it isn't.  Richard already answered your question:  Your alert
  coerces the object into a string, which implicitly calls the toString
 methodon it, which (in the case of a link)returnsthehref.  If you
  actually _try_ what he suggested, you'll see that he's right.

  Here's a page demonstrating this stuff:
 http://pastie.org/422726

  If you run that in a browser, the output is:
  * * * *
  links.length = 4
  typeof links[0] = object
  links[0].id = one
  links[0].href=http://prototypejs.org/api
  links[0].innerHTML = Prototype API
  links[0] dumped via implicit call to toString:http://prototypejs.org/api
  -
  The full array:
  Link one (Prototype API) links tohttp://prototypejs.org/api
  Link two (Google (U.S.)) links tohttp://www.google.com/
  Link four (Example) links tohttp://example.com/
  Link five (BBC News) links tohttp://news.bbc.co.uk/
  * * * *

  HTH,
  --
  T.J. Crowder
  tj / crowder software / com
  Independent Software Engineer, consulting services available

  On Mar 20, 5:01 pm, tkane2000 tkthomp...@gmail.com wrote:
  hmm, well, links[0] is returning a string, not the a object, so those
  will both return null.

  The question is why does this statement:
  $$('.gallery .thumb .listItem .thumbHolder');
  return thevalueofhref(a string) and not that a object?

  Thanks!

  On Mar 20, 6:38 am, Richard Quadling rquadl...@googlemail.com wrote:

   Almost certainly you are seeing the results of a toString()method
   kicking in for the objects (or similar).

   Try ...

   alert(links[0]: + links[0].id + ':' + links[0].href);

   Richard Quadling.

   2009/3/20 tkane2000 tkthomp...@gmail.com:

How come the $$() functionreturnsthevalueof thehrefwhen
selecting ananchortaginsteadof thetagitself?  ...I've had mixed
results for this btwn FF and IE6, but it's consistant in the code
below.  Anyone know what I'm doing wrong here or if there's a
workaround?

div id=gallery
       div class=thumb
               div class=listItem
                       ahref=/asdfasdf/asdfsdf.jhtml 
class=thumbHolderthis is some
text/abr /
                       ahref=/asdfasdf/asdfsdf.jhtml 
class=thumbHolderthis is some
text/abr /
               /div
       /divbr /
       div class=thumb
               div class=listItem
                       ahref=/asdfasdf/234234.jhtml 
class=thumbHolderthis is some
text 21/abr /
                       ahref=/asdfasdf/234234.jhtml 
class=thumbHolderthis is some
text 23/abr /
               /div
       /div
/div

script type=text/javascript
       var links = $$('.gallery .thumb .listItem .thumbHolder');
       alert(links[0]: + links[0]);
/script

   --
   -
   Richard Quadling
   Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498r=213474731
   Standing on the shoulders of some very clever giants!

 Thanks TJ. Still learning. PHP is my bag. Prototype is very much being
 added to it though.

 --
 -
 Richard Quadling
 Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498r=213474731
 Standing on the shoulders of some very clever giants!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Overwrite onClick in IE

2009-03-23 Thread tkane2000

...long story as to why I need to do this, but I have a set of links
that already have onClick event handlers set and I need to overwrite
them.  If I could just get them to return false and do nothing else, I
could use the observe method to the the rest.  Below is an example of
what I mean:

The following script works in FF3, but not IE7:

div id=gallery
div class=thumb
div class=listItem
a href=http://www.cnn.com;
onClick=location.href='http://www.google.com'
class=thumbHolderthis is some text/abr /
/div
/div
/div

script type=text/javascript
var links = $$('#gallery .thumb .listItem .thumbHolder');
links[0].writeAttribute({onClick:alert('test');return false;}); //
works in FF, but not IE
/script

Any idea why this works in FF but not IE?  Any hacks to get around
it?  (keep in mind I can't edit the anchor tag directly...must do it
through js)

Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---