Hi Tony,
Hope ur using Jquery
Add the class to the remove link and add the following line of code
> <div class="fields">
> <%= f.error_messages %>
>
> <p>
> <%= f.text_field :content %>
>
> <% unless f.object.new_record? %>
> <%= link_to_remove_fields "remove", f,:class=>"remove" %>
> <% end %>
> </p>
> </div>
$(document).ready(function(){
$(".remove").eq(0).remove()
})
Tony Tony wrote:
> Hi all,
>
> I apologize for the funky subject of this post.
>
> I have a partial I created while recreating a railscasts example (nested
> resources part 2 -
> http://railscasts.com/episodes/197-nested-model-form-part-2) and I've
> come to a halt.
>
> What I want to do is force a question to be asked if this is a new
> "survey". Basically I want to build one question in the new action and
> display it in the form and remove the link_to_remove_fields helper - BUT
> I also want to be able to add AND remove new questions. While making
> sure that the inital question cannot be removed.
>
> Hopefully this makes sense. Below is my partial code:
>
> [code]
>
> <div class="fields">
> <%= f.error_messages %>
>
> <p>
> <%= f.text_field :content %>
>
> <% unless f.object.new_record? %>
> <%= link_to_remove_fields "remove", f %>
> <% end %>
> </p>
> </div>
>
> [/code]
>
>
> I added <% unless f.object.new_record? %> to omit the remove link on the
> new action and this works. However when someone clicks the 'add
> question' (code not shown but identical to the railscast code) it
> display the fields but obviously also omits the remove link for the
> newly added questions.
>
> How can I omit the first remove link but show the remove link for newly
> added questions in the new action? Please let me know if you need more
> info!
>
>
> Thank you!
> -Tony
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.