Ruby on Rails Thursday, September 5, 2013

You would show and hide the element with JavaScript, but create it in Rails. Simple example:

<div id="favorite-color" style="display:none">
<%= form_for @knight do |f| %>
<%= f.label :favorite_color, 'What\'s your favorite color?' %>
<%= f.collection_select :favorite_color, %w(red green blue aaaaah), :to_s, :titleize, :prompt => true %>
<%= f.submit %>
</div>

<button id="color-button">Take the challenge!</button>

//script
$('color-button').observe('click', function(){
$('favorite-color').show();
});

Walter

On Sep 5, 2013, at 9:35 AM, Jorge C. wrote:

> Joel Pearson wrote in post #1120757:
>> I believe the standard way to do this would be to show a previously
>> hidden div containing a form.
>
> And that is possible using Rails or is it Javascript?
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/04c28d9a2ee2a59cb2c415eb9dab5b4d%40ruby-forum.com.
> For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/A89FD321-5C52-4C37-AA7C-43FF172CDED0%40wdstudio.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment