Hello all,

I have a helper function called "add_link" which will insert html to a
partial.

- ProjectsHelper -
def add_link(name, irb=nil)
    link_to_function name do |page|
      page.insert_html :top, :irbs, :partial => 'projects/irb', :object
=> Irb.new, :locals => { :irb_id => irb }
    end
end

- _irb.html.erb -
<!-- project/_irb.html.erb -->
<div class="irb">
<!-- Note: look into creating a helper method for error messages -->
  <% new_or_existing = irb.new_record? ? 'new' : 'existing' %>
  <% prefix = "project[#{new_or_existing}_irb_attributes][]" %>
  <% error_messages_for :irb %>

  <!-- Display IRBs -->
  <% fields_for prefix, irb do |irb_form| -%>
  <p>
    <%= irb_form.text_field "IRB" %>           <!-- text field value
option -->

    <%= link_to_function "remove", "jQuery(this).fadeOut(500, function()
{ $(this).up('.irb').remove(); } );" %>
  </p>
  <% end -%>
</div>

How can I pass an id to the text field like the "<%= text_field_tag
"IRB", irb_id %>"

I would like to display the IRB value in the text field when inserted.

Thanks for any help with this.

JohnM
-- 
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 post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.


Reply via email to