Nerian / bootstrap-datepicker-rails

A Datepicker for Twitter Bootstrap, integrated with Rails assets pipeline
MIT License
649 stars 182 forks source link

Datepicker startDate / endDate is not working #131

Closed Deimos620 closed 7 years ago

Deimos620 commented 7 years ago

I am using recent version of bootstrap-datepicker-rails (https://github.com/eternicode/bootstrap-datepicker version 1.6.4). I am trying to set startdate / enddate , not working. Here is my code. var startDate = "1987-07-01"; var endDate = "1991-10-06"; $(".datepicker").datepicker({ format: 'yyyy-mm-dd', startDate: startDate, endDate: endDate });

But this is not working for me, always keep starting from current date. I've googled and tried several solutions , they aren't working for me. Would you like to provide solution to help me?

Nerian commented 7 years ago

What's is the HTML fro that component? Is there any errors in the console?

https://bootstrap-datepicker.readthedocs.io/en/stable/options.html#format

Deimos620 commented 7 years ago

I don't have any error in console. Here is html code. I've used Rails erb / helper. <%= f.text_field :birthday, class: 'form-control datepicker' ``%> It is compiled to : <input class="form-control datepicker" type="text" name="profile[birthday]" id="profile_birthday">

Nerian commented 7 years ago

Mmm, I don't why would this fail. It seems correct to me.

Try using the format 'mm/dd/yyyy' and change the data accordingly. Let's see if the datepicker is getting the data at all.

Deimos620 commented 7 years ago

Unfortunately, It doesn't work for me. I changed the format 'mm/dd/yyyy'. Then, the picked date format is changed correctly , but startdate / enddate is not working , too. I see , bootstrap-datepicker-rails is using https://github.com/uxsolutions/bootstrap-datepicker for bootstrap datepicker javascript library. What I can't understand is its demo is not working too. Please visit here: https://uxsolutions.github.io/bootstrap-datepicker

Nerian commented 7 years ago

Indeed, the demo is not working. Perhaps the version 1.7, which is what is being used in that demo, is broken.

Personally I am using https://github.com/zpaulovics/datetimepicker-rails in my new projects. It integrates with simpleform quite nicely.

Deimos620 commented 7 years ago

Thanks. I will move to it. Closing issue.