Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minDate format "new Date(miliseconds)" not supported? #32

Open
JeanMertz opened this issue Nov 3, 2012 · 2 comments
Open

minDate format "new Date(miliseconds)" not supported? #32

JeanMertz opened this issue Nov 3, 2012 · 2 comments

Comments

@JeanMertz
Copy link

It seems when I do:

= f.datepicker :expire, dateFormat: 'dd-mm-yy', minDate: 'new Date()'

Things work correctly (that is, I can't go lower than todays date)

However, this doesn't work:

= f.datepicker :expire, dateFormat: 'dd-mm-yy', minDate: 'new Date(1289430000000)'

This time, I shouldn't be able to go lower than "11-11-2010" but I still can.

I verified that this should work by using the following, which worked correctly:

:javascript
  $( "#datepicker" ).datepicker({ minDate: new Date(1289430000000) });

Any idea what might be going on here?

@JeanMertz
Copy link
Author

Thinking some more about this (after being head down on this issue for the past two hours) I just realize that it could be because the javascript doesn't get evaluated and so only hard values work here? (like -10 or "+1W"). But then why would new Date() work but new Date(1289430000000) won't?

So, the question then remains, can I set fixed min/max date instead of a relative date using this gem? (all examples in the README show relative date ranges)

@albertopq
Copy link
Owner

Hi!
The point is that parameter is meant to be in javascript, but we are passing it through Rails. The plugin doesn't support evaluating the javascript (at least, it doesn't yet). In fact, new Date() isn't working either, if you set whatever string you want you'll se the same result.

You can use other options instead a Date object:

http://api.jqueryui.com/datepicker/#option-minDate

I would suggest using a string following the dateFormat ('26-06-2013', if your dateFormat is dd-mm-yy, for example)

So,

= f.datepicker :expire, dateFormat: 'dd-mm-yy', minDate: '26-06-2013'

should work. I'll add some clarifications in the README file.

Let me know if that helps.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants