Hi All, Inside my app\views\expenses\new.html.erb file, I had the code: <% form_for(@expense) do |f| %> [snip] <p> <%= f.label :vendor %><br /> <%= f.text_field :vendor %> <br /> <div id="vendor_droplist> <%= select_tag "test", options_for_select(@current_vendors.collect { |v| v.nickname }), {:multiple => true} %> </div> </p> It brought up a list of vendor-names immediately under my Vendors textbox, which worked great as far as I was concerned. Then I tried to turn it into a real drop-down: 1. I added style="display:none" to the div so that the drop-down was hidden when the page opened 2. I added <%= button_to_function("ShowList", %<page.toggle :vendor_droplist> ) %> following the text_field Hiding the drop-down worked, but the button failed to restore it. Validating the resulting HTML revealed the a div is not permitted in the scope of a form. To solve this I removed the <div> opening and closing tags and: 1. added the id to the select_tag: <%= select_tag "test" :id="vendor_droplist", options_for_select(@current_vendors.collect { |v| v.nickname }), {:multiple => true} %> 2 added it with a comma <%= select_tag "test", :id="vendor_droplist", options_for_select(@current_vendors.collect { |v| v.nickname }), {:multiple => true} %> Neither these nor any other change I tried worked. So what''s the Rail''s way of solving this problem? I''m running Rails 2.3.5, Ruby 1.8.6, WinXP-Pro/SP3, Firefox 3.6, MySQL 5.0.37-community-nt, Mongrel. Thanks in Advance, Richard -- 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.
On 22 March 2010 21:18, RichardOnRails <RichardDummyMailbox58407-gP6xRNRnnqSxhq/XJNNIW0EOCMrvLtNR@public.gmane.org> wrote:> Hi All, > > Inside my app\views\expenses\new.html.erb file, I had the code: > > <% form_for(@expense) do |f| %> > [snip] > <p> > <%= f.label :vendor %><br /> > <%= f.text_field :vendor %> > <br /> > <div id="vendor_droplist> > <%= select_tag "test", > options_for_select(@current_vendors.collect { |v| > v.nickname }), > {:multiple => true} %> > </div> > </p> > > It brought up a list of vendor-names immediately under my Vendors > textbox, which worked great as far as I was concerned. Then I tried > to turn it into a real drop-down: > 1. I added style="display:none" to the div so that the drop-down was > hidden when the page opened > 2. I added <%= button_to_function("ShowList", > %<page.toggle :vendor_droplist> ) %> following the text_field > > Hiding the drop-down worked, but the button failed to restore it. > Validating the resulting HTML revealed the a div is not permitted in > the scope of a form.You certainly can have divs inside a form. I think you must have misinterpreted the message. Can you roll your version control system back to the version that caused this and post the results of the validation and the bit of html causing the problem. Colin> > To solve this I removed the <div> opening and closing tags and: > 1. added the id to the select_tag: > <%= select_tag "test" :id="vendor_droplist", > options_for_select(@current_vendors.collect { |v| > v.nickname }), > {:multiple => true} %> > 2 added it with a comma > <%= select_tag "test", :id="vendor_droplist", > options_for_select(@current_vendors.collect { |v| > v.nickname }), > {:multiple => true} %> > > Neither these nor any other change I tried worked. So what''s the > Rail''s way of solving this problem? > > I''m running Rails 2.3.5, Ruby 1.8.6, WinXP-Pro/SP3, Firefox 3.6, MySQL > 5.0.37-community-nt, Mongrel. > > Thanks in Advance, > Richard > > -- > 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. > >-- 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.
Hi Colin, I still don''t have subversion not git working. But I pretty sure that http://www.pastie.org/881730 presents it all: three aspects of "new expenses": the .erb, the htm and the validator''s. A second look a the validation failure led me to think that substituting object for div would solve my problem. It doesn''t run any differently. I haven''t sought the validator''s opinion yet. Regards, Richard On Mar 22, 5:49 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 22 March 2010 21:18, RichardOnRails > > > > <RichardDummyMailbox58...-gP6xRNRnnqSxhq/XJNNIW0EOCMrvLtNR@public.gmane.org> wrote: > > Hi All, > > > Inside my app\views\expenses\new.html.erb file, I had the code: > > > <% form_for(@expense) do |f| %> > > [snip] > > <p> > > <%= f.label :vendor %><br /> > > <%= f.text_field :vendor %> > > <br /> > > <div id="vendor_droplist> > > <%= select_tag "test", > > options_for_select(@current_vendors.collect { |v| > > v.nickname }), > > {:multiple => true} %> > > </div> > > </p> > > > It brought up a list of vendor-names immediately under my Vendors > > textbox, which worked great as far as I was concerned. Then I tried > > to turn it into a real drop-down: > > 1. I added style="display:none" to the div so that the drop-down was > > hidden when the page opened > > 2. I added <%= button_to_function("ShowList", > > %<page.toggle :vendor_droplist> ) %> following the text_field > > > Hiding the drop-down worked, but the button failed to restore it. > > Validating the resulting HTML revealed the a div is not permitted in > > the scope of a form. > > You certainly can have divs inside a form. I think you must have > misinterpreted the message. Can you roll your version control system > back to the version that caused this and post the results of the > validation and the bit of html causing the problem. > > Colin > > > > > To solve this I removed the <div> opening and closing tags and: > > 1. added the id to the select_tag: > > <%= select_tag "test" :id="vendor_droplist", > > options_for_select(@current_vendors.collect { |v| > > v.nickname }), > > {:multiple => true} %> > > 2 added it with a comma > > <%= select_tag "test", :id="vendor_droplist", > > options_for_select(@current_vendors.collect { |v| > > v.nickname }), > > {:multiple => true} %> > > > Neither these nor any other change I tried worked. So what''s the > > Rail''s way of solving this problem? > > > I''m running Rails 2.3.5, Ruby 1.8.6, WinXP-Pro/SP3, Firefox 3.6, MySQL > > 5.0.37-community-nt, Mongrel. > > > Thanks in Advance, > > Richard > > > -- > > 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 athttp://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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Mar 22, 9:18 pm, RichardOnRails <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> wrote:> It brought up a list of vendor-names immediately under my Vendors > textbox, which worked great as far as I was concerned. Then I tried > to turn it into a real drop-down: > 1. I added style="display:none" to the div so that the drop-down was > hidden when the page opened > 2. I added <%= button_to_function("ShowList", > %<page.toggle :vendor_droplist> ) %> following the text_field > > Hiding the drop-down worked, but the button failed to restore it. > Validating the resulting HTML revealed the a div is not permitted in > the scope of a form. >button_to_function creates a form, which would result in a form nested inside a form, which isn''t allowed. Fred -- 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.
Hi Frederick, As I mentioned to Colin, I would start a new thread on this question, which is at http://groups.google.com/group/rubyonrails-talk/tree/browse_frm/thread/d0ca35d39de37478/cd6ed92bd974e311?rnum=1&_done=%2Fgroup%2Frubyonrails-talk%2Fbrowse_frm%2Fthread%2Fd0ca35d39de37478%3F#doc_cd6ed92bd974e311 Thanks for looking into my problem. But I just noticed that there is another response on this thread.> button_to_function creates a form, which would result in a form nested inside a form, which isn''t allowed.Wow. As I mentioned on the other thread, I posted code on that seemed clean from a Rails perspective and from an HTML perspective. So, if button_to_function is inappropriate for forms, can I specify an image that, when clicked, would toggle a page with the appropriate id specified? Is there an example on the web that you''d recommend? Best wishes, Richard BTW, my current code, with HTML generated and Validation results is at http://www.pastie.org/882256 On Mar 22, 7:00 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Mar 22, 9:18 pm, RichardOnRails<RichardDummyMailbox58...@USComputerGurus.com> wrote: > > It brought up a list of vendor-names immediately under my Vendors > > textbox, which worked great as far as I was concerned. Then I tried > > to turn it into a real drop-down: > > 1. I added style="display:none" to the div so that the drop-down was > > hidden when the page opened > > 2. I added <%= button_to_function("ShowList", > > %<page.toggle :vendor_droplist> ) %> following the text_field > > > Hiding the drop-down worked, but the button failed to restore it. > > Validating the resulting HTML revealed the a div is not permitted in > > the scope of a form. > > button_to_function creates a form, which would result in a form nested > inside a form, which isn''t allowed. > > Fred-- 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.
On 23 Mar, 07:33, RichardOnRails <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> wrote:> Hi Frederick, > > As I mentioned to Colin, I would start a new thread on this question, > which is athttp://groups.google.com/group/rubyonrails-talk/tree/browse_frm/threa... > > Thanks for looking into my problem. > > But I just noticed that there is another response on this thread. > > > button_to_function creates a form, which would result in a form nested inside a form, which isn''t allowed. > > Wow. As I mentioned on the other thread, I posted code on that > seemed clean from a Rails perspective and from an HTML perspective. > > So, if button_to_function is inappropriate for forms, can I specify > an image that, when clicked, would toggle a page with the appropriate > id specified? Is there an example on the web that you''d recommend? >Sorry, slight mixup up; button_to creates a form, but looks like button_to_remote doesn''t. Your javscript fragment is incorrect though - the () on a method call aren''t optional in javascript, and what you''ve got there looks more like RJS than javascript - the whole page[] construct is an RJS-ism. If you want to use RJS then you need to use the block form of button_to_function Fred> Best wishes, > Richard > > BTW, my current code, with HTML generated and Validation results is athttp://www.pastie.org/882256 > > On Mar 22, 7:00 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > On Mar 22, 9:18 pm, RichardOnRails<RichardDummyMailbox58...@USComputerGurus.com> wrote: > > > It brought up a list of vendor-names immediately under my Vendors > > > textbox, which worked great as far as I was concerned. Then I tried > > > to turn it into a real drop-down: > > > 1. I added style="display:none" to the div so that the drop-down was > > > hidden when the page opened > > > 2. I added <%= button_to_function("ShowList", > > > %<page.toggle :vendor_droplist> ) %> following the text_field > > > > Hiding the drop-down worked, but the button failed to restore it. > > > Validating the resulting HTML revealed the a div is not permitted in > > > the scope of a form. > > > button_to_function creates a form, which would result in a form nested > > inside a form, which isn''t allowed. > > > Fred-- 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.
On 22 March 2010 22:32, RichardOnRails <RichardDummyMailbox58407-gP6xRNRnnqSxhq/XJNNIW0EOCMrvLtNR@public.gmane.org> wrote:> Hi Colin, > > I still don''t have subversion not git working.Well the answer to that problem is obvious. Colin> But I pretty sure that > http://www.pastie.org/881730 presents it all: three aspects of "new > expenses": the .erb, the htm and the validator''s. > > A second look a the validation failure led me to think that > substituting object for div would solve my problem. It doesn''t run > any differently. I haven''t sought the validator''s opinion yet. > > Regards, > Richard > > On Mar 22, 5:49 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> On 22 March 2010 21:18, RichardOnRails >> >> >> >> <RichardDummyMailbox58...-gP6xRNRnnqSxhq/XJNNIW0EOCMrvLtNR@public.gmane.org> wrote: >> > Hi All, >> >> > Inside my app\views\expenses\new.html.erb file, I had the code: >> >> > <% form_for(@expense) do |f| %> >> > [snip] >> > <p> >> > <%= f.label :vendor %><br /> >> > <%= f.text_field :vendor %> >> > <br /> >> > <div id="vendor_droplist> >> > <%= select_tag "test", >> > options_for_select(@current_vendors.collect { |v| >> > v.nickname }), >> > {:multiple => true} %> >> > </div> >> > </p> >> >> > It brought up a list of vendor-names immediately under my Vendors >> > textbox, which worked great as far as I was concerned. Then I tried >> > to turn it into a real drop-down: >> > 1. I added style="display:none" to the div so that the drop-down was >> > hidden when the page opened >> > 2. I added <%= button_to_function("ShowList", >> > %<page.toggle :vendor_droplist> ) %> following the text_field >> >> > Hiding the drop-down worked, but the button failed to restore it. >> > Validating the resulting HTML revealed the a div is not permitted in >> > the scope of a form. >> >> You certainly can have divs inside a form. I think you must have >> misinterpreted the message. Can you roll your version control system >> back to the version that caused this and post the results of the >> validation and the bit of html causing the problem. >> >> Colin >> >> >> >> > To solve this I removed the <div> opening and closing tags and: >> > 1. added the id to the select_tag: >> > <%= select_tag "test" :id="vendor_droplist", >> > options_for_select(@current_vendors.collect { |v| >> > v.nickname }), >> > {:multiple => true} %> >> > 2 added it with a comma >> > <%= select_tag "test", :id="vendor_droplist", >> > options_for_select(@current_vendors.collect { |v| >> > v.nickname }), >> > {:multiple => true} %> >> >> > Neither these nor any other change I tried worked. So what''s the >> > Rail''s way of solving this problem? >> >> > I''m running Rails 2.3.5, Ruby 1.8.6, WinXP-Pro/SP3, Firefox 3.6, MySQL >> > 5.0.37-community-nt, Mongrel. >> >> > Thanks in Advance, >> > Richard >> >> > -- >> > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> > For more options, visit this group athttp://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@googlegroups.com. > 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks very much for taking another look at my problem.> If you want to use RJS then you need > to use the block form of button_to_functionHere''s the best my brain could come up with <%# = button_to_function("ShowList", %<page["vendor_droplist"].toggle> ) %> <%= button_to_function("ShowList") { page["vendor_droplist"].toggle } %> but compilation of new.html.erb with that change gives me: ==undefined local variable or method `page'' for #<ActionView::Base: 0x467eaf4> Extracted source (around line #17): 14: <%= f.label :vendor %><br /> 15: <%= f.text_field :vendor %> 16: <%# = button_to_function("ShowList", %<page["vendor_droplist"].toggle> ) %> 17: <%= button_to_function("ShowList") { page["vendor_droplist"].toggle } %> 18: <br /> 19: <div id="vendor_droplist" style="display:none"> 20: <%= select_tag "list", == If it''s not too much trouble, can you point me to website that provides detail on the alternative forms, or even better, show me a correct form of #17 above. Sorry for being so obtuse ... I''m a Rails nubie, but aspiring higher :-) -- Richard On Mar 23, 4:11 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 23 Mar, 07:33, RichardOnRails > > > > <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> wrote: > > Hi Frederick, > > > As I mentioned to Colin, I would start a new thread on this question, > > which is athttp://groups.google.com/group/rubyonrails-talk/tree/browse_frm/threa... > > > Thanks for looking into my problem. > > > But I just noticed that there is another response on this thread. > > > > button_to_function creates a form, which would result in a form nested inside a form, which isn''t allowed. > > > Wow. As I mentioned on the other thread, I posted code on that > > seemed clean from a Rails perspective and from an HTML perspective. > > > So, if button_to_function is inappropriate for forms, can I specify > > an image that, when clicked, would toggle a page with the appropriate > > id specified? Is there an example on the web that you''d recommend? > > Sorry, slight mixup up; button_to creates a form, but looks like > button_to_remote doesn''t. Your javscript fragment is incorrect though > - the () on a method call aren''t optional in javascript, and what > you''ve got there looks more like RJS than javascript - the whole > page[] construct is an RJS-ism. If you want to use RJS then you need > to use the block form of button_to_function > > Fred > > > Best wishes, > > Richard > > > BTW, my current code, with HTML generated and Validation results is athttp://www.pastie.org/882256 > > > On Mar 22, 7:00 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > > On Mar 22, 9:18 pm, RichardOnRails<RichardDummyMailbox58...@USComputerGurus.com> wrote: > > > > It brought up a list of vendor-names immediately under my Vendors > > > > textbox, which worked great as far as I was concerned. Then I tried > > > > to turn it into a real drop-down: > > > > 1. I added style="display:none" to the div so that the drop-down was > > > > hidden when the page opened > > > > 2. I added <%= button_to_function("ShowList", > > > > %<page.toggle :vendor_droplist> ) %> following the text_field > > > > > Hiding the drop-down worked, but the button failed to restore it. > > > > Validating the resulting HTML revealed the a div is not permitted in > > > > the scope of a form. > > > > button_to_function creates a form, which would result in a form nested > > > inside a form, which isn''t allowed. > > > > Fred-- 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.