85
rated 0 times
[
92]
[
7]
/ answers: 1 / hits: 16460
/ 14 Years ago, thu, january 27, 2011, 12:00:00
When using the form_for
helper and a text_field
call, Ruby on Rails will generate a unique id for the <input />
element that it outputs. How can I generate the same id for later inclusion into JavaScript generated later?
<%= form_for @user do |f| %>
<%= f.text_field :username %>
<% end %>
Then later in the page:
<%= javascript_tag do %>
$('<%= id of the :username field %>').doSomethingReallyCool();
<% end %>
More From » ruby-on-rails