I don''t really know what all you''re trying to do with your
question
numbered 3, so I am just going to overlook that for right now.
Here''s how you do your first two. I''m not going to write
anything
using any sort of ''Behavior'', just good old fashioned
Prototypey
goodness.
Assuming you have an HTML page like this:
<ul id="links">
<li><a href="somePage1.html">Some Link
1</a></li>
<li><a href="somePage2.html">Some Link
2</a></li>
<li><a href="somePage3.html">Some Link
3</a></li>
</ul>
<div id="div_to_update">Click A Link!</div>
<script type="text/javascript">
$(''links).observe(''click'',function(event) {
// find out which link we''ve clicked
var element = Event.element(event);
if ( element.tagName.toLowerCase() == ''a'' ) {
// stop the link from executing
Event.stop(event);
new
Ajax.Updater(''div_to_update'',element.getAttribute(''href''));
}
}.bindAsEventListener());
</script>
All too easy. Enjoy.
-E
On 2/12/07, bbbs <bbbs.bbbs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> Hello all, forgive my newbie style question, but I am finding it very
> diffiucult to find any tutorials or excample code that can assist
>
> I have the following scenario.
>
> I have an unordered list of links on a page, each has an external page
> as a href.
>
> I would like to do the following :
>
> 1) Make use of Behaviour to override the href with an "onclick"
event,
> this would allow for a gracefull degrade for browsers with no
> javascript.
>
> 2) Make it so that if one of the links is clicked an AJAX request is
> made to populate a div on the same page
>
> 3) Make it so that if a link is clicked the style of theat link is
> changed to a "clicked state", and all the other links in the list
are
> reverted to an "unclicked" state.
>
> Just looking for pointers on each of the above, any help appreciated.
>
> BBBS
>
>
> >
>
--
Eric Ryan Harrison
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---