Dear All,

I am trying to override the behavior of certain links on a page based
on their class. It seemed like this should be easy with Prototype but
I ran across some results I don't understand. When I attach a click
event to the link objects with plain innerHTML (e.g. no <b> or <i>
tags), the event passes  the proper 'a' object to my function. If the
innerHTML of the 'a' object contains any other objects, such as '<b>',
it passes that instead. To whit:

--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/
TR/html4/strict.dtd">
<html>
        <head>
                <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
                <title>Element Select Bug Test</title>
                <script src="lib/prototype.js" type="text/javascript"></script>
                <script type="text/javascript">
                        function runTest () {
                                $$('a.amiabug').each(function (o) {  
Event.observe(o, 'click',
foobar); });
                        }
                        function foobar (e) {
                                Event.stop(e);
                                alert(Event.element(e).inspect());
                        }

                        Event.observe(window, 'load', runTest);
                </script>
        </head>
        <body>
                <a class="amiabug" href="#">Link element with plain text 
innerHTML</
a>
                <br /><br />
                <a class="amiabug" href="#"><b>Link element with bolded 
innerHTML</
b></a>
        </body>
</html>
-----------------

Clicking the first link returns "<a class=amiabug>" while the second
link returns "<b>"

Is this is bug, or is there some logic I am missing, and if so, how
can I reliably get the 'a' object passed to my function when clicked?

Best Regards,

V


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to