Gareth,it's not the problem you described.
I debuged my code carefully and found the mistake.
It showed an error "$("menu").observe is not a function".
I change $("menu").observe to Event.observe($
("menu"),'click' ,function(event){...}),and it works now.
But about that error's reason,i can't figure it out.Because the API
Docs shows that ""$("menu").observe" should work.
Does anyone know the reason?I appreciate for your help.
A fact is that my prototype is version 1.5.0,but the API Docs'
prototype version 1.5.1 rc1,and i don't know the latter's changes to
the front.
On 4月5日, 上午10时09分, "Gareth Evans" <[EMAIL PROTECTED]> wrote:
> It looks like you're applying your observer to the parent menu element, not
> the child a-tags underneath?
>
> Gareth
>
> On 4/5/07, Vin <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi,
> > After checking Event.stop in Prototype's API Docs,i wrote an
> > example to test Event.stop method's function just now.
> > The test scene is like:
> > Some hyperlinks with their respective href property(link to other
> > pages).
> > Now,i wanna use Event.stop method to cancel those hyperlinks'
> > default behaviors,it means that they no longer link to those pages
> > specified in href attribute in expect,right?
> > So,i write my code as below:
> > Event.observe(window,"load",init);
> > function init(){
> > $("menu").observe("click",function(event){
> > var target=Event.element(event);
> > alert(target.innerHTML);//for test,it show
> > nothing when click a
> > link.
> > Event.stop(event);
> > });
> > }
> > But it doesn't work in expect,the hyperlinks are still behaving their
> > default behaviors,linking to other pages...
> > Why?
> > The exact example please view on:
> >http://pastie.caboo.se/51837
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---