Ruby On Rails: jQuery datepicker only works when refresh page -
the problem having when navigate through form page , click on date_sent on text field, jquery supposed pop-up datepicker. however, nothing @ first, when refresh page works.
i sure problem turbolinks, because assume javascript not loaded because of turbolinks. however, not want remove turbolinks because page renders slow without it. how can make work?
application.js
//= require jquery //= require jquery-ui/datepicker //= require jquery_ujs //= require bootstrap-sprockets //= require cocoon //= require turbolinks //= require_tree .
application.scss
*= require_self *= require jquery-ui/datepicker *= require_tree . */ @import 'bootstrap-sprockets'; @import 'bootstrap'; @import 'sites';
form.coffee
jquery -> $('#send_date').datepicker()
form.html.erb
<div class="form-group" > <%= f.label :date_sent, class: 'control-label' %><br> <%= f.text_field :date_sent, id: 'send_date' %> </div>
did try turbolinks:load
event ?
$(document).on "turbolinks:load", ->
instead:
$(document).ready, ->
Comments
Post a Comment