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.

Hoffa
  • 197
  • 1
  • 1
  • 12

1 Answers1

1

As always, I figure out my problem 10 seconds after posting the question.

The answer is to attach the jquery right on the text_field, thusly:

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

Joy.

Hoffa
  • 197
  • 1
  • 1
  • 12