Requesting information from user

17 views
Skip to first unread message

Jorge C.

unread,
Sep 5, 2013, 9:33:24 AM9/5/13
to rubyonra...@googlegroups.com
Hi,

I need to "popup" a message to the user in order he can choose an
option. It is not a YES-NO option but almost the same (has has to choose
among two options). It has to be a message with a question and two
buttons.

Is that possible on Rails?

Thanks!

Jorge

--
Posted via http://www.ruby-forum.com/.

Joel Pearson

unread,
Sep 5, 2013, 9:34:33 AM9/5/13
to rubyonra...@googlegroups.com
I believe the standard way to do this would be to show a previously
hidden div containing a form.

Jorge C.

unread,
Sep 5, 2013, 9:35:57 AM9/5/13
to rubyonra...@googlegroups.com
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?

Walter Lee Davis

unread,
Sep 5, 2013, 9:51:00 AM9/5/13
to rubyonra...@googlegroups.com
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
> --
> 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-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@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.

Reply all
Reply to author
Forward
0 new messages