How do I connect jQuery Datepicker to my Ruby on Rails form?

前端 未结 7 2250
谎友^
谎友^ 2020-12-13 18:22

I\'m trying to use the jQuery Datepicker to set a date field in my Ruby on Rails form, but I can\'t work out how to do it. Can someone point me in the right direction?

相关标签:
7条回答
  • 2020-12-13 19:11

    I used albertopq's jquery_datepicker that albertopq mentions and it works with regular forms, nested attributes, etc. It made things very easy for me. jquery_datepicker also correctly passes options to datepicker's necessary javascript calls.

    Here's an example from one of my nested forms:

    <%= f.datepicker 'availability', :minDate => 0, :maxDate => "+8Y", :tab_index => autotab %>
    

    minDate and maxDate are passed to datepicker and tab_index is put into the text field html. (autotab is just my form helper to advance the tab + 1...better for me than hardcoding it).

    0 讨论(0)
提交回复
热议问题