Questions tagged [cocoon-gem]

Cocoon makes creating dynamic nested forms using jQuery easy. It works with formtastic, simple_form, and default forms.

Useful links for Cocoon

499 questions
5
votes
1 answer

Trigger cocoon add_association from javascript

I am using cocoon and I want to automatically add a child record when a date(can be multiple dates) in a date picker is selected. I can trap the date selections in coffeescript like this, but I don't know how to get a child record added through…
Craig McGuff
  • 3,968
  • 6
  • 30
  • 35
5
votes
2 answers

How to render one association automatically with cocoon

I have cocoon working with nested form, if you click add field link it inserts input fields. How do I render first input automatically, and then insert additional inputs when "add field" is clicked ?
alexndm
  • 2,899
  • 5
  • 24
  • 25
5
votes
2 answers

Using Cocoon (Nested Forms) and jQuery sortable together

I currently have an input form generated using Cocoon and would like to make the input fields created by it sortable (using sortable from jQuery-ui). The code for the nested form is: <%= f.simple_fields_for :checkout_procedures do |procedure| %> …
4
votes
1 answer

Cocoon links are not working

I user Rails 4 and Cocoon gem. In fact, I know the problem - cocoon.js is not compiled into application.js as I can see in the browser. I do require cocoon in application.js and have the gem installed. I do not use turbolinks. What else might cause…
user3292534
4
votes
1 answer

Rails cocoon nested form: undefined method `reflect_on_association' for NilClass:Class

I am trying to build a form with nested resources in my rails 4 app. I am using the cocoon gem. Each step will have substeps, and I'd like to allow the user to add as many substeps to the form and he/she would like. Step.rb class Step <…
Ron M
  • 773
  • 2
  • 10
  • 22
4
votes
1 answer

ActiveAdmin has_many form not saved if parent model is new and is NOT NULL in child model

I have two models, Room and Student. Room has_many Students. Student belongs_to Room. I got an error Room can't be blank when I try to add Student to Room during creating a new Room. My guess is that, upon submission, child object (student) is saved…
Chu Xiwen
  • 41
  • 3
4
votes
1 answer

Cannot send variable to partial using Cocoon (Rails 3)

i'm using Rails 3, with standard rails form and Cocoon gem. I want to send a variable to a partial through the 'link_to_add_association' using the 'render_options' provided by the gem, but i cannot make it work. The view from the partial is…
4
votes
1 answer

Unique Nested Child Identifiers for Tab Links using Twitter Bootstrap & Cocoon

I have a Ruby on Rails application with Twitter Bootstrap tabs within a partial, and multiple instances of that partial can be added by the user using Simple Form and Cocoon. In order for the tab links to work properly, I must have unique names…
4
votes
2 answers

cocoon gem install / usage?

i am trying to use cocoon for nested ajax form coupled with formtastic my rails version Rails 3.2.3 i have put gem "cocoon" im my gemfile and did a bundle install then in my elements/_form.html.erb: <%= semantic_form_for @element do |f| %> …
Matoeil
  • 6,851
  • 11
  • 54
  • 77
4
votes
1 answer

Rails with simple_form: add new table row with link_to_add

I'm having problems adding a new table row by clicking the link_to_add function link.
4
votes
3 answers

cocoon, link_to_remove_association with confirm?

is there an easy way to add confirm dialog box that would appear when user clicks link_to_remove_association ? cocoon gem is really great, I wonder if it has such a ready option ?? if not, can I use jQuery to cancel or let go the event ? Thanks,
simo
  • 23,342
  • 38
  • 121
  • 218
3
votes
2 answers

Rails 3.1. Cocoon link_to_add_association example needed

pls show any example of using Cocoon's 'link_to_add_association' with html_options. https://github.com/nathanvda/cocoon Documentation says: html_options: extra html-options (see link_to) There are two extra options that allow to conrol the placement…
BazZy
  • 2,429
  • 3
  • 21
  • 26
3
votes
0 answers

How to create nested forms using rails 3 and datamapper?

my models in Datamapper are: Project: require "dm-accepts_nested_attributes" class Project include DataMapper::Resource property :id, Serial property :project_title, String has n, :tasks accepts_nested_attributes_for…
Deepak
  • 106
  • 6
3
votes
1 answer

Dealing with many hidden fields in nested forms

I have a has_many through association and I'm getting an error because I'm not passing the :ingredient_id as an array (or something like that, it's just a guess :) ) Error:Couldn't find Ingredient with ID=1 for MealIngredient with…
3
votes
1 answer

Clear all nested models if parent has field of particular value

Trying to figure out the best way of clearing nested models if its parent has a field of a particular value. I have models Company, Person and Role. A company has_many people and a person can be a contractor, which is determined by a boolean value…
neanderslob
  • 2,633
  • 6
  • 40
  • 82
1
2
3
33 34