Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cocoon is creating multiple fields and also not rendering the date_select fields #320

Closed
kumar91gopi opened this issue Oct 9, 2015 · 3 comments

Comments

@kumar91gopi
Copy link

The issue is the date_select fields are not rendered properly i am not getting the drop-down and also initially when i click add education button 2 or 3 new fileds are rendered (date_select not rendered properly) but when i reload the page and then click add education button then its renders just one field(and that is what i want) but date_select fields are still not rendered properly

from and to are the date_select fields and i got 3 new fields jus by clicking add education once :(
capture

here is my nested form

form

here is my _education_fields partial

education

here is my model

class Profile < ActiveRecord::Base
  has_many :educations, :dependent => :destroy
  accepts_nested_attributes_for :educations,
                                  :allow_destroy => true,
                                  :reject_if     => proc { |attributes| attributes['institute'].blank? }

  validates :name, presence: true,  length: { maximum: 50 }

end
@nathanvda
Copy link
Owner

The multiple insertions on one click sounds like a turbolinks problem. That would be related to where you include your cocoon.js. The rendering of the date_select is not a cocoon problem :)

@kumar91gopi
Copy link
Author

I have included cocoon.js in assests/javascripts/application.js .
And please can you suggest me what could be the problem with date_select?

@nathanvda
Copy link
Owner

Ok, including in the application.js sounds right. Where do you include the application.js in your layout? It should be in the header (head).

I have no idea what the problem is with the date-select, gathering from your screenshot, I would blame your css, as I do not see any styling for input fields. Normally date_select renders three drop-downs. You could easily verify if your HTML is correct by inspecting your html (in chrome: right-click on the location and select "Inspect Element").

If you need more help concercing the date-select, I suggest you ask it on stackoverflow.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants