Abba
2008-Feb-06 14:42 UTC
Object does not support this property or method... obviously only in IE
Hi all, I have setup a small class to manage my menu: Event.observe(window, ''load'', init, false); var myMenu; function init() { myMenu = new Menu; } var Menu = Class.create({ initialize: function() { this.activeElement = null; this.activeElementChild = null; }, expand: function(id, thisItem) { this.hideAll(); this.activeElement = thisItem; this.activeElementChild = $(id.toString()); this.activeElement.addClassName(''active''); this.activeElementChild.show(); }, hideAll: function () { if (this.activeElement != null) { this.activeElementChild.hide(); this.activeElement.removeClassName(''active''); } $$(''#menuNavigation a.active'').each( function(item){ item.removeClassName(''active''); }); try { $(''staticThirdLevel'').hide(); } catch(err){} } }) I''ve setup the menu item like this: <a onclick="myMenu.expand(1, this)">Users</a> <a onclick="myMenu.expand(2, this)">Dogs</a> ..... etc, etc..... The problem is that when it arravies to this line: this.activeElement.addClassName(''active''); only in IE (i.e. in Firefox is working) i got the following error: Object does not support this property or method any idea? Thanks --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Nikodim Lazarov
2008-Feb-06 14:57 UTC
Re: Object does not support this property or method... obviously only in IE
Hi, Try using the $ method in the expand: this.activeElement = $(thisItem); -- Niko 2008/2/6, Abba <cercatop-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> > > Hi all, I have setup a small class to manage my menu: > > Event.observe(window, ''load'', init, false); > var myMenu; > > function init() { > myMenu = new Menu; > } > > var Menu = Class.create({ > initialize: function() { > this.activeElement = null; > this.activeElementChild = null; > }, > expand: function(id, thisItem) { > this.hideAll(); > this.activeElement = thisItem; > this.activeElementChild = $(id.toString()); > > this.activeElement.addClassName(''active''); > this.activeElementChild.show(); > }, > hideAll: function () { > if (this.activeElement != null) { > this.activeElementChild.hide(); > this.activeElement.removeClassName(''active''); > } > $$(''#menuNavigation a.active'').each( function(item){ > item.removeClassName(''active''); > }); > > try > { > $(''staticThirdLevel'').hide(); > } > catch(err){} > > } > }) > > I''ve setup the menu item like this: > > <a onclick="myMenu.expand(1, this)">Users</a> > <a onclick="myMenu.expand(2, this)">Dogs</a> > ..... etc, etc..... > > The problem is that when it arravies to this line: > > this.activeElement.addClassName(''active''); > > only in IE (i.e. in Firefox is working) i got the following error: > > Object does not support this property or method > > any idea? Thanks > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Abba
2008-Feb-06 15:18 UTC
Re: Object does not support this property or method... obviously only in IE
Thanks, it works. But in the end is like passing the Id of the element and then make a getElementByID... is not what i was expecting :( It looked more clean as it was before but was working only with Firefox... but nevermind. Ciao On Feb 6, 3:57 pm, "Nikodim Lazarov" <nlaza...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > Try using the $ method in the expand: > > this.activeElement = $(thisItem); > > -- > Niko > > 2008/2/6, Abba <cerca...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > > > > Hi all, I have setup a small class to manage my menu: > > > Event.observe(window, ''load'', init, false); > > var myMenu; > > > function init() { > > myMenu = new Menu; > > } > > > var Menu = Class.create({ > > initialize: function() { > > this.activeElement = null; > > this.activeElementChild = null; > > }, > > expand: function(id, thisItem) { > > this.hideAll(); > > this.activeElement = thisItem; > > this.activeElementChild = $(id.toString()); > > > this.activeElement.addClassName(''active''); > > this.activeElementChild.show(); > > }, > > hideAll: function () { > > if (this.activeElement != null) { > > this.activeElementChild.hide(); > > this.activeElement.removeClassName(''active''); > > } > > $$(''#menuNavigation a.active'').each( function(item){ > > item.removeClassName(''active''); > > }); > > > try > > { > > $(''staticThirdLevel'').hide(); > > } > > catch(err){} > > > } > > }) > > > I''ve setup the menu item like this: > > > <a onclick="myMenu.expand(1, this)">Users</a> > > <a onclick="myMenu.expand(2, this)">Dogs</a> > > ..... etc, etc..... > > > The problem is that when it arravies to this line: > > > this.activeElement.addClassName(''active''); > > > only in IE (i.e. in Firefox is working) i got the following error: > > > Object does not support this property or method > > > any idea? Thanks--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Justin Perkins
2008-Feb-06 15:23 UTC
Re: Object does not support this property or method... obviously only in IE
On Feb 6, 2008 9:18 AM, Abba <cercatop-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Thanks, it works. But in the end is like passing the Id of the element > and then make a getElementByID... is not what i was expecting :(The $() function not does what the getElementByID() function does, but it also does so much more, including extending the built-in node object to include all Prototype''s Element methods so that you can use them. IE requires you to do this. -justin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Abba
2008-Feb-06 15:30 UTC
Re: Object does not support this property or method... obviously only in IE
Now everything is clear. Thanks for helping me to understand. bye On Feb 6, 4:23 pm, "Justin Perkins" <justinperk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Feb 6, 2008 9:18 AM, Abba <cerca...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Thanks, it works. But in the end is like passing the Id of the element > > and then make a getElementByID... is not what i was expecting :( > > The $() function not does what the getElementByID() function does, but > it also does so much more, including extending the built-in node > object to include all Prototype''s Element methods so that you can use > them. IE requires you to do this. > > -justin--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---