0
votes

In a Rails app I had a textfield/ jquery datepicker that degraded to date select fields (day, month, year). I'm midway through a major update, including updating gems and Rails version. My jquery function is now rendering three datepickers (one for each select field). Why would this happen? Or, what has changed within Rails that would cause this?

My code

<%= simple_form_for(@model,...... do |f| %>
  <%= f.input :date, as: :date, order: [:day, :month, :year], input_html: { class: "date-selector" %>
<% end %>

And coffeescript

jQuery -> 
  data = $(".date-selector").data('date')
  $(".date-selector").replaceWith(
    $("<input type='text' class='date-picker' id='prerep_date' value='" + data + "' name='prerep[date]' >").datepicker)
1

1 Answers

1
votes

Have a look at the outputted HTML in your browser and see check to see the containing HTML tag for the select boxes, use that as the replace pointer in your JQuery code.

The three box output is now standard in rails as I understand it.