0

I've run into a strange problem where I can't get a date picker to update the field in a rails app. I've tried a few different date pickers, so it's not a problem with the jquery plugin. Same results.

There's nothing strange about what I'm trying to do.

<div class="datepicker field">
  <label>Date of Birth</label>
  <%= f.text_field :dob %>
</div>

I have tried both with manual turbolinks workarounds..

var ready;
ready = function() { .... everything in here }
$(document).ready(ready);
$(document).on('page:load', ready);

and with jquery-turbolinks gem. It always gives me the same result - the jquery will load the picker, but the field does not get updated.

I believe I've got it narrowed down to Semantic UI at this point, but I'm happy to be proven wrong.

application.js :

//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//= require semantic-ui
//= require pickadate/picker 
//= require pickadate/picker.date 
//= require turbolinks
//= require_tree .

relevant portion of local js:

$(function() {
  $('.datepicker').pickadate()
});

Any clues as to what I'm missing? Thanks.

4

1 回答 1

1

与往常一样,我在发布问题 10 秒后发现了我的问题。

答案是将 jquery 附加在 text_field 上,因此:

<div class="field" >
  <label>Date of Birth</label>
  <%= f.text_field :dob, id: "datepicker" %>
</div>

喜悦。

于 2015-04-10T01:12:30.530 回答