hi, im gettin lost with the subject. need some pointers: Usermodel: validates_presence_of :companyname, :if => :is_company? <p><%= f.label "Are u representing a company?" %> <%= f.check_box :is_company, :onclick => "new Effect.toggle(''div_company''); //if($(''user_is_company'').value == 0){$(''user_is_company'').value =1;} //if($(''user_is_company'').value == 1){$(''user_is_company'').value =0;} //alert(escape($(''user_is_company'').value))" %> <div id="div_company" style="display:none;" > <fieldset style="width: 70%"> <legend> Details </legend> <p><%= f.label "Company Name" %><br /> <%= f.text_field :companytitle %></p> ...... my problem is: if someone is signing up AND checking the box "is_company" the company detail div appears. now, if the company details dont pass the validation, the page gets naturally reloaded and the checkbox is_company stays checked but the div is hidden. tried several ways , but all end up in chaos.... does anyone have any working snippets?/thx -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
You need to add condition, where if a box is checked show div. On Jun 30, 7:11 pm, tom <tomabr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi, > im gettin lost with the subject. need some pointers: > > Usermodel: > validates_presence_of :companyname, :if => :is_company? > > <p><%= f.label "Are u representing a company?" %> > <%= f.check_box :is_company, :onclick => "new Effect.toggle(''div_company''); > //if($(''user_is_company'').value == 0){$(''user_is_company'').value =1;} > //if($(''user_is_company'').value == 1){$(''user_is_company'').value =0;} > //alert(escape($(''user_is_company'').value))" %> > > <div id="div_company" style="display:none;" > > <fieldset style="width: 70%"> > <legend> Details </legend> > > <p><%= f.label "Company Name" %><br /> > <%= f.text_field :companytitle %></p> > ...... > > my problem is: > if someone is signing up AND checking the box "is_company" the company > detail div appears. now, if the company details dont pass the validation, > the page gets naturally reloaded and the checkbox is_company stays checked > but the div is hidden. > > tried several ways , but all end up in chaos.... > > does anyone have any working snippets?/thx-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
ok thx On Wed, Jun 30, 2010 at 8:59 PM, Me <chabgood-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You need to add condition, where if a box is checked show div. > > On Jun 30, 7:11 pm, tom <tomabr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > hi, > > im gettin lost with the subject. need some pointers: > > > > Usermodel: > > validates_presence_of :companyname, :if => :is_company? > > > > <p><%= f.label "Are u representing a company?" %> > > <%= f.check_box :is_company, :onclick => "new > Effect.toggle(''div_company''); > > //if($(''user_is_company'').value == 0){$(''user_is_company'').value =1;} > > //if($(''user_is_company'').value == 1){$(''user_is_company'').value =0;} > > //alert(escape($(''user_is_company'').value))" %> > > > > <div id="div_company" style="display:none;" > > > <fieldset style="width: 70%"> > > <legend> Details </legend> > > > > <p><%= f.label "Company Name" %><br /> > > <%= f.text_field :companytitle %></p> > > ...... > > > > my problem is: > > if someone is signing up AND checking the box "is_company" the company > > detail div appears. now, if the company details dont pass the validation, > > the page gets naturally reloaded and the checkbox is_company stays > checked > > but the div is hidden. > > > > tried several ways , but all end up in chaos.... > > > > does anyone have any working snippets?/thx > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.