after creating an element how can I add a onMouseOver ? var mydiv = document.createElement(''div''); mydiv.innerHTML = "foo"; mydiv.onMouseOver = "color=red"; is this only done via ''observe'' thankyouverymuch --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
In Prototype 1.6: var mydiv = new Element(''div'',{''class'':''blah''}).update(''foo'').observe (''mouseover'',function(){this.setStyle({''color'':''red''})}); Gotta love chaining! Walter On Mar 3, 2008, at 9:30 PM, dave wrote:> > > after creating an element how can I add a onMouseOver ? > > var mydiv = document.createElement(''div''); > mydiv.innerHTML = "foo"; > mydiv.onMouseOver = "color=red"; > > is this only done via ''observe'' > > thankyouverymuch > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Gotta love chaining, indeed. I would rather go with toggling className instead of messing with the styles, but I guess that''s just a matter of taste. - kangax On Mar 3, 10:16 pm, Walter Lee Davis <wa...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote:> In Prototype 1.6: > > var mydiv = new Element(''div'',{''class'':''blah''}).update(''foo'').observe > (''mouseover'',function(){this.setStyle({''color'':''red''})}); > > Gotta love chaining! > > Walter > > On Mar 3, 2008, at 9:30 PM, dave wrote: > > > after creating an element how can I add a onMouseOver ? > > > var mydiv = document.createElement(''div''); > > mydiv.innerHTML = "foo"; > > mydiv.onMouseOver = "color=red"; > > > is this only done via ''observe'' > > > thankyouverymuch--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Mar 4, 12:30 pm, dave <david.humphe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> after creating an element how can I add a onMouseOver ? > > var mydiv = document.createElement(''div''); > mydiv.innerHTML = "foo"; > mydiv.onMouseOver = "color=red";Javascript object properties are case sensitive and event handlers expect a function object, so: mydiv.onmouseover = function(){this.style.color = ''red'';} ... // Don''t allow circular references to presist mydiv = null; An alternative to the first line is to define the function elsewhere and use a reference: function setRed(){ this.style.color = ''red''; } mydiv.onmouseover = setRed; ... mydiv = null; -- Rob --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I agree. I was just trying to stick as close to the original as possible. Walter On Mar 3, 2008, at 10:49 PM, kangax wrote:> > Gotta love chaining, indeed. > I would rather go with toggling className instead of messing with the > styles, but I guess that''s just a matter of taste. > > - kangax > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---