javascript - Rails 4 datetimepicker and cocoon gem -


hi have problem cocoon: https://github.com/nathanvda/cocoon , datetimepicker:http://xdsoft.net/jqplugins/datetimepicker/. when add through cocoon new nested field calendar not showing up. think must user cocoon after:insert event in javascript file tried every way , not working. views: costs.html.haml

= simple_form_for [:partners, @car], url: wizard_path |f|   = f.simple_fields_for :costs |cost|     = render 'cost_fields', f: cost   #links     = link_to_add_association '+', f, :costs   = link_to t('cars.back'), previous_wizard_path   = f.submit t('cars.next'), class: 'btn btn-primary' 

and cost_fields partial:

.nested-fields   %table.table.table-striped.table-bordered.dupa     %thead       %th.field         = f.association :cost_type       %th.field           = f.input :netto_price       %th.field         = f.input :document_number        %th.field         = f.association :vat          %th.field         = f.input :type_of_cost       %th.field         = f.input :date, as: :string , :input_html => { :class => 'date' }    = link_to_remove_association "x", f 

any ideas?

as post eludes, because dynamically added elements not yet in dom.

try add class or id before nested simple fields (this in dom), e.g.:

#container     = f.simple_fields_for :costs |cost|         = render 'cost_fields', f: cost     

then in javascript file:

$(document).on('ready page:change', function() {     $('#container').on('cocoon:after-insert', function() {        $('.datetimepicker').datetimepicker();     }) }) 

also, i've used datepicker gem, allows generate wrapper input/custom date/time fields

= f.input :date, :as => :date_picker 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -