Hello, I have a code on a RJS where I want to check if an element in the DOM has child elements, if not, show a message. 1.page["event_"+@event.id.to_s].visual_effect :fade #This works 2.page << "if $(''single_blog_info_box_480'').childElements().length =0 {" 3.page["message"].visual_effect :appear 4.page << "}" Line 1 is working. It removes an event from the view. The problem is in line 2. I am calling childElements on a div called ''single_blog_info_box_480'' (which contains the events). The idea is to make a message appear when there are no more events left. The thing is that I currently have 3 events and everytime the RJS is executed it shows the same 3 events even though events have become hidden. Can somebody guide me on how to do this or what the problem is? Thanks, Elioncho --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 30 Oct 2008, at 21:55, elioncho wrote:> > Hello, I have a code on a RJS where I want to check if an element in > the DOM has child elements, if not, show a message. > > 1.page["event_"+@event.id.to_s].visual_effect :fade #This works > 2.page << "if $(''single_blog_info_box_480'').childElements().length => 0 {" > 3.page["message"].visual_effect :appear > 4.page << "}" > > Line 1 is working. It removes an event from the view. The problem is > in line 2. I am calling childElements on a div called > ''single_blog_info_box_480'' (which contains the events). The idea is to > make a message appear when there are no more events left. The thing is > that I currently have 3 events and everytime the RJS is executed it > shows the same 3 events even though events have become hidden. Can > somebody guide me on how to do this or what the problem is? >you need to have () surrounding the condition. Fred> Thanks, > > Elioncho > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I added the () but that''s not the problem. I added the next alert and it shows the events length. But if I remove another event it still shows the same number. page << "alert($(''single_blog_info_box_480'').childElements().length)" On Oct 30, 5:05 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 30 Oct 2008, at 21:55, elioncho wrote: > > > > > > > Hello, I have a code on a RJS where I want to check if an element in > > the DOM has child elements, if not, show a message. > > > 1.page["event_"+...@event.id.to_s].visual_effect :fade #This works > > 2.page << "if $(''single_blog_info_box_480'').childElements().length => > 0 {" > > 3.page["message"].visual_effect :appear > > 4.page << "}" > > > Line 1 is working. It removes an event from the view. The problem is > > in line 2. I am calling childElements on a div called > > ''single_blog_info_box_480'' (which contains the events). The idea is to > > make a message appear when there are no more events left. The thing is > > that I currently have 3 events and everytime the RJS is executed it > > shows the same 3 events even though events have become hidden. Can > > somebody guide me on how to do this or what the problem is? > > you need to have () surrounding the condition. > > Fred > > > Thanks, > > > Elioncho--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
why don''t you write 2--4 line into a single line ? page << "if ($(''single_blog_info_box_480'').childElements().length =0 ){$(''message'').Appear;}" On Oct 31, 7:35 am, elioncho <elion...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I added the () but that''s not the problem. I added the next alert and > it shows the events length. But if I remove another event it still > shows the same number. > > page << "alert($(''single_blog_info_box_480'').childElements().length)" > > On Oct 30, 5:05 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > On 30 Oct 2008, at 21:55, elioncho wrote: > > > > Hello, I have a code on a RJS where I want to check if an element in > > > the DOM has child elements, if not, show a message. > > > > 1.page["event_"+...@event.id.to_s].visual_effect :fade #This works > > > 2.page << "if $(''single_blog_info_box_480'').childElements().length => > > 0 {" > > > 3.page["message"].visual_effect :appear > > > 4.page << "}" > > > > Line 1 is working. It removes an event from the view. The problem is > > > in line 2. I am calling childElements on a div called > > > ''single_blog_info_box_480'' (which contains the events). The idea is to > > > make a message appear when there are no more events left. The thing is > > > that I currently have 3 events and everytime the RJS is executed it > > > shows the same 3 events even though events have become hidden. Can > > > somebody guide me on how to do this or what the problem is? > > > you need to have () surrounding the condition. > > > Fred > > > > Thanks, > > > > Elioncho--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
The childElements length never changes when I make the event disappear. It''s like it remains with what initially is loaded on the html eventhough I have hide this elements. On Oct 30, 7:02 pm, boblu <bobl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> why don''t you write 2--4 line into a single line ? > > page << "if ($(''single_blog_info_box_480'').childElements().length => 0 ){$(''message'').Appear;}" > > On Oct 31, 7:35 am, elioncho <elion...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I added the () but that''s not the problem. I added the next alert and > > it shows the events length. But if I remove another event it still > > shows the same number. > > > page << "alert($(''single_blog_info_box_480'').childElements().length)" > > > On Oct 30, 5:05 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > > On 30 Oct 2008, at 21:55, elioncho wrote: > > > > > Hello, I have a code on a RJS where I want to check if an element in > > > > the DOM has child elements, if not, show a message. > > > > > 1.page["event_"+...@event.id.to_s].visual_effect :fade #This works > > > > 2.page << "if $(''single_blog_info_box_480'').childElements().length => > > > 0 {" > > > > 3.page["message"].visual_effect :appear > > > > 4.page << "}" > > > > > Line 1 is working. It removes an event from the view. The problem is > > > > in line 2. I am calling childElements on a div called > > > > ''single_blog_info_box_480'' (which contains the events). The idea is to > > > > make a message appear when there are no more events left. The thing is > > > > that I currently have 3 events and everytime the RJS is executed it > > > > shows the same 3 events even though events have become hidden. Can > > > > somebody guide me on how to do this or what the problem is? > > > > you need to have () surrounding the condition. > > > > Fred > > > > > Thanks, > > > > > Elioncho--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
elioncho wrote:> The childElements length never changes when I make the event > disappear. It''s like it remains with what initially is loaded on the > html eventhough I have hide this elements. >I don''t use these effects a lot, but the fade effect in prototype/ scriptaculous is probably setting the css ''display'' property to none to take it out of the visual display of the document. It''s still sitting there in the dom, so ''childElements'' is probably counting it; it''s just that it doesn''t appear in the visual flow. -- Daniel Bush --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks all of you for help. Daniel I think that''s what''s happening. I''ll try another approach. Elioncho On Oct 30, 9:44 pm, Daniel Bush <dlb.id...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> elioncho wrote: > > The childElements length never changes when I make the event > > disappear. It''s like it remains with what initially is loaded on the > > html eventhough I have hide this elements. > > I don''t use these effects a lot, but the fade effect in prototype/ > scriptaculous is probably setting the css ''display'' property to none > to take it out of the visual display of the document. It''s still > sitting there in the dom, so ''childElements'' is probably counting it; > it''s just that it doesn''t appear in the visual flow. > > -- > Daniel Bush--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sent from my iPhone On 30 Oct 2008, at 22:35, elioncho <elioncho-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I added the () but that''s not the problem. I added the next alert and > it shows the events length. But if I remove another event it still > shows the same number. >Well it was syntaxtically incorrect javascript. Effects like fade don''t remove elements from the page, they just hide then. You could remove them after the fade. Fred> page << "alert($(''single_blog_info_box_480'').childElements().length)" > > > > > On Oct 30, 5:05 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> On 30 Oct 2008, at 21:55, elioncho wrote: >> >> >> >> >> >>> Hello, I have a code on a RJS where I want to check if an element in >>> the DOM has child elements, if not, show a message. >> >>> 1.page["event_"+...@event.id.to_s].visual_effect :fade #This works >>> 2.page << "if $(''single_blog_info_box_480'').childElements().length >>> =>>> 0 {" >>> 3.page["message"].visual_effect :appear >>> 4.page << "}" >> >>> Line 1 is working. It removes an event from the view. The problem is >>> in line 2. I am calling childElements on a div called >>> ''single_blog_info_box_480'' (which contains the events). The idea >>> is to >>> make a message appear when there are no more events left. The >>> thing is >>> that I currently have 3 events and everytime the RJS is executed it >>> shows the same 3 events even though events have become hidden. Can >>> somebody guide me on how to do this or what the problem is? >> >> you need to have () surrounding the condition. >> >> Fred >> >>> Thanks, >> >>> Elioncho > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---