Nest of inequity and despair
Today's instalment covers a few tricks I've encountered while working on Wami this last week:
Bootstrap has a JS plugin called typeahead, which is crap. Some guy tried to extend it and his was crap also.
I used to use jQuery's autocomplete, but that was crap in Bootstrap. Until this guy re-styled it to work. That's the shit.
Absolutely rocks, use it! waaaay simple
Am I the only guy who thinks of
when I read:
Also very usefull, if only to get the link_to_add and link_to_remove helpers. You can read more here.
<%= f.fields_for :tasks do |task_form| %> <%= task_form.text_field :name %> <%= task_form.link_to_remove "Remove this task" %> <% end %> <%= f.link_to_add "Add a task", :tasks %>
Nested_form also works nicely inside simple_form: simple_nested_form_for
If like me you seem to be a corner-case magnet, then you have wondered how to use fields_for to render fields, but not the ones included in the model already. In my case, I wanted to add documents to a model, but not render a field set for any existing documents.
The answer ( in the context of the original documentation):
<%= f.fields_for :tasks,  do |task_form| %> <%= task_form.text_field :name %> <%= task_form.link_to_remove "Remove this task" %> <% end %> <%= f.link_to_add "Add a task", :tasks %>
This will let you add child items, without cluttering the view with existing items