I've got the following code in my attempt to provide the subject
functionality, lines 20-29 in view:
<%= image_tag "DownArrow.jpg" options =
{ onclick=page["vendor_droplist"].show } %>
<br>
<div name="vendor_droplist">
<%= select_tag "test",
options_for_select(@current_vendors.collect { |v|
v.nickname }),
{:multiple => true} %>
</div>
Until I put in the options on image tag and added the div, this code
display a list of vendor nicknames. Now I have several problems:
1. Syntax error in line 20 where an identifier was encountered where a
right-paren was expected (see below)
2. I don't know how to make the vendor_droplist initially hidden
I've Googled for "Rails Ajax toggled item" and got a number of hits
but no apparent answer. I'll keep poking around the Web, but I
appreciate some suggestion(s).
Thanks in advance,
Richard
Showing app/views/expenses/new.html.erb where line #20 raised:
compile error
K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/views/expenses/
new.html.erb:20: syntax error, unexpected tIDENTIFIER, expecting ')'
@output_buffer.concat " "; @output_buffer.concat(( image_tag
"DownArrow.jpg" options =
{ onclick=page["vendor_droplist"].show } ).to_s);
@output_buffer.concat "\n"
^
K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/views/expenses/
new.html.erb:20: odd number list for Hash
@output_buffer.concat " "; @output_buffer.concat(( image_tag
"DownArrow.jpg" options =
{ onclick=page["vendor_droplist"].show } ).to_s);
@output_buffer.concat "\n"
^
Extracted source (around line #20):
17: <p>
18: <%= f.label :vendor %><br />
19: <%= f.text_field :vendor %>
20: <%= image_tag "DownArrow.jpg" options =
{ onclick=page["vendor_droplist"].show } %>
21: <br>
22: <div name="vendor_droplist">
23: <%= select_tag "test",
Trace of template inclusion: app/views/expenses/new.html.erb
RAILS_ROOT: K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS
Application Trace | Framework Trace | Full Trace
K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/views/expenses/
new.html.erb:59:in `compile!'
K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/controllers/
expenses_controller.rb:30:in `new'
<%# = image_tag "DownArrow.jpg" options =
{ onclick=page["vendor_droplist"].show } %>
<br>
<div id="vendor_droplist", style="display:none">
<%= select_tag "test",
options_for_select(@current_vendors.collect { |v|
v.nickname }),
{:multiple => true} %>
</div>
On Mar 21, 12:07 am, RichardOnRails
<%# = image_tag "DownArrow.jpg" options =
{ onclick=page["vendor_droplist"].show } %>
<br>
<div id="vendor_droplist", style="display:none">
<%= select_tag "test",
options_for_select(@current_vendors.collect { |v|
v.nickname }),
{:multiple => true} %>
</div>
On Mar 21, 12:07 am, RichardOnRails
<RichardDummyMailbox58...@USComputerGurus.com> wrote:
<%= button_to_function("ShowList",
%<page["vendor_droplist"].show> ) %>
<br>
<div id="vendor_droplist", style="display:none">
<%= select_tag "test",
options_for_select(@current_vendors.collect { |v|
v.nickname }),
{:multiple => true} %>
</div>
On Mar 21, 12:37 am, RichardOnRails
I don't know whether it is still relevant after your later emails but
the problem here is (at least in part) that you are missing a comma
after "DownArrow.jpg" and a > after options =
Colin
Have you checked the html generated by the above to make sure it is
generating what you expect?
Colin
> --
> 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 rubyonra...@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
Your "check the HTML" tip is *great* ... it's now in my debugging
arsenal.
> comma missing
That was a tip on my img-base code. I'll get back to that because I
like the down-arrow image better that ShowList button version, which
is close to working.
My last next-to-last problem in this code is that the ShowList button
doesn't toggle the visibility of the vendor_droplist. My guess is
that the onclick value is RJS that should have been translated into
JavaScript at this point.
My final problem is how to add on-click code to the return vendor
items so that clicking any of them toggles (or hides: same effect in
this context) the vendor_droplist. But I can probably do this on my
own correctly.
Below is the ERB code and the generated HTML for the vendor input. As
I've done so often, thank you for looking into my problem. I am
learning this stuff steadily so I should post questions much less
frequently in just a few weeks.
Best wishes,
Richard
Vendor input code
=============
<p>
<%= f.label :vendor %><br />
<%= f.text_field :vendor %>
<%= button_to_function("ShowList",
%<page[:vendor_droplist].toggle> ) %>
<br>
<div id="vendor_droplist", style="display:none">
<%= select_tag "test",
options_for_select(@current_vendors.collect { |v|
v.nickname }),
{:multiple => true} %>
</div>
</p>
Generated HTML
============
<p>
<label for="expense_vendor">Vendor</label><br />
<input id="expense_vendor" name="expense[vendor]" size="30"
type="text" />
<input onclick="page[:vendor_droplist].toggle;" type="button"
value="ShowList" />
<br>
<div id="vendor_droplist", style="display:none">
<select id="test" multiple="multiple" name="test[]"><option
value="IBM">IBM</option>
<option value="Fed Ex">Fed Ex</option></select>
</div>
</p>
On Mar 21, 5:04 am, Colin Law <clan...@googlemail.com> wrote:
> On 21 March 2010 04:07, RichardOnRails
>
Another tip is to install the Html Validator add-on to Firefox and it
will automatically validate your pages as you develop, this often
shows up the reason why something is not working as you expect.
Colin
Your "how's the HTML" question really did the job:
<div> tag not allowed within the scope of a <form> tag.
Which means the my .erb can't have:
<% form_for(@expense) do |f| %>
[snip]
<div id="vendor_droplist" style="display:none">
<%= select_tag "test",
options_for_select(@current_vendors.collect { |v|
v.nickname }),
{:multiple => true} %>
</div>
More importantly to me, it means that:
<input onclick="page.toggle :vendor_droplist;" type="button"
value="ShowList" />
won't work inside that form.
I'm going to post a new question on how to fix this while I scour the
documentation to figure it out myself.
Again, thank you for sharing your expertise with me,
Richard
On Mar 21, 10:18 am, Colin Law <clan...@googlemail.com> wrote:
> On 21 March 2010 10:49, RichardOnRails
>
> <RichardDummyMailbox58...@uscomputergurus.com> wrote:
> > Hi Colin,
>
> > Your "check the HTML" tip is *great* ... it's now in my debugging
> > arsenal.
>
> Another tip is to install the Html Validator add-on to Firefox and it
> will automatically validate your pages as you develop, this often
> shows up the reason why something is not working as you expect.
>
> Colin
On Mar 21, 10:18 am, Colin Law <clan...@googlemail.com> wrote:
> On 21 March 2010 10:49, RichardOnRails
>
> Your "how's the HTML" question really did the job:
> <div> tag not allowed within the scope of a <form> tag.
What gives you that idea? It's simply not true.
--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
twitter: @hassan
Thanks for joining the conversation. I ran my the HTML page which was
generated by my .erb. I had a form_for with an embedded div and the
HTML page had an embedded div. W3C didn't like it. The details are
at http://www.pastie.org/881730. Now that I look at it again,
perhaps the Object tag in place of the Div will work.
Best wishes,
Richard
On Mar 22, 4:51 pm, Hassan Schroeder <hassan.schroe...@gmail.com>
wrote:
> On Mon, Mar 22, 2010 at 1:35 PM, RichardOnRails
>
> <RichardDummyMailbox58...@uscomputergurus.com> wrote:
> > Your "how's the HTML" question really did the job:
> > <div> tag not allowed within the scope of a <form> tag.
>
> What gives you that idea? It's simply not true.
>
> --
> Hassan Schroeder ------------------------ hassan.schroe...@gmail.com
> twitter: @hassan
It's not that you have a <form> with a nested <div> that the W3C is
complaining at, it's that you have a <p> with a nested <div> - lines
33 and 39 of your NewExpensePage.htm
> Thanks for joining the conversation. I ran my the HTML page which was
> generated by my .erb. I had a form_for with an embedded div and the
> HTML page had an embedded div. W3C didn't like it. The details are
> at http://www.pastie.org/881730.
Read line 11 of your validation pastie -- that is almost certainly your
problem.
Getting used to reading the HTML DTD(s) would be a good idea :-)
I've got clean code that validates. http://www.pastie.org/882256
displays:
- new.html.erb
- HTML generated for new.html.erb
- Validation for generated html, which has one spurious (IMHO) warning
The code that's problematic for me is:
<%# This begins the vendor-name code %>
<%= f.label :vendor %><br />
<%= f.text_field :vendor %>
<%= button_to_function("ShowList",
%<page["vendor_droplist"].toggle> ) %>
<br />
<div id="vendor_droplist" style="display:none">
<%= select_tag "list",
options_for_select(@current_vendors),
:multiple => true, :size => 3 %>
</div>
<%# This is the end of the vendor-name code %>
The vendor_droplist without the style allows vendors to be displayed
in a drop-down-style list.
With the "hide style", I expected that clicking the ShowList button
would cause the list to be displayed, but that does not happen.
Do you any further idea about how to get that button working?
Thanks in Advance for any other ideas you may have.
On Mar 22, 6:02 pm, Michael Pavling <pavl...@gmail.com> wrote:
> On 22 March 2010 21:51, RichardOnRails
>
> <RichardDummyMailbox58...@uscomputergurus.com> wrote:
> > Hi Hassan,
>
> > Thanks for joining the conversation. I ran my the HTML page which was
> > generated by my .erb. I had a form_for with an embedded div and the
> > HTML page had an embedded div. W3C didn't like it. The details are
> > athttp://www.pastie.org/881730. Now that I look at it again,
> > perhaps the Object tag in place of the Div will work.
>
> It's not that you have a <form> with a nested <div> that the W3C is
> complaining at, it's that you have a <p> with a nested <div> - lines
> 33 and 39 of your NewExpensePage.htm
On Mar 22, 6:02 pm, Michael Pavling <pavl...@gmail.com> wrote:
> On 22 March 2010 21:51, RichardOnRails
>
> <RichardDummyMailbox58...@uscomputergurus.com> wrote:
> > Hi Hassan,
>
> > Thanks for joining the conversation. I ran my the HTML page which was
> > generated by my .erb. I had a form_for with an embedded div and the
> > HTML page had an embedded div. W3C didn't like it. The details are
> > athttp://www.pastie.org/881730. Now that I look at it again,
On Mar 22, 6:11 pm, Hassan Schroeder <hassan.schroe...@gmail.com>
wrote:
> On Mon, Mar 22, 2010 at 2:51 PM, RichardOnRails
>
> <RichardDummyMailbox58...@uscomputergurus.com> wrote:
> > Thanks for joining the conversation. I ran my the HTML page which was
> > generated by my .erb. I had a form_for with an embedded div and the
> > HTML page had an embedded div. W3C didn't like it. The details are
> > athttp://www.pastie.org/881730.
>
> Read line 11 of your validation pastie -- that is almost certainly your
> problem.
>
> Getting used to reading the HTML DTD(s) would be a good idea :-)
>
> --
> Hassan Schroeder ------------------------ hassan.schroe...@gmail.com
> twitter: @hassan