Skip to content

Maybe like that?#30

Closed
litvinenkow wants to merge 1 commit intoarschmitz:masterfrom
litvinenkow:patch-1
Closed

Maybe like that?#30
litvinenkow wants to merge 1 commit intoarschmitz:masterfrom
litvinenkow:patch-1

Conversation

@litvinenkow
Copy link

No description provided.

@indrimuska
Copy link
Contributor

I think that your solution is not correct.
The datepicker is initialized with .datepicker(this.options) as you can see here and here.
Maybe you need to update also these lines with no attributes .datepicker()?

Personally, I think that if the widget doesn't cause any issues there's no need to change that line.

@litvinenkow
Copy link
Author

indrimuska, if you getting doubt about my guess, than i prove you that i'm right
cause i had spent more than 4 hours trying to find that issue
as you can see here i can not set date format for my country
http://jsbin.com/tuxuc/1/edit
but here below everything works fine
http://jsbin.com/moxuq/1/edit

can you explain this behavior for me? what i'm doing wrong?

@litvinenkow litvinenkow reopened this Apr 15, 2014
@indrimuska
Copy link
Contributor

If you just want to change the date format you have simply to add data-date-attribute="dd.mm.yy" on your input field http://jsbin.com/indrimuska/85/edit.
Otherwise you can choose one of the solutions described in #29.

@litvinenkow
Copy link
Author

what if i want to set maximum and minimum values or exclude some dates?

@indrimuska
Copy link
Contributor

You can choose a min and max date, but I don't know any solutions that lets the UI datepicker to exclude some specific days.

http://jsbin.com/indrimuska/88/edit

@arschmitz
Copy link
Owner

@indrimuska is right this solution is not correct this.options is options for the particular instance you want to modify these with the values from defaults, the defaults are then over written by data attributes, which are overwritten by options passed via the options hash in js. this is the correct order of precedence for the options. @indrimuska is also write about the issue with your code being duplicate id's see the issue he linked to. Im going to close this as not a bug.

@arschmitz arschmitz closed this Apr 15, 2014
@arschmitz
Copy link
Owner

@litvinenkow also for excluding certain days you want http://api.jqueryui.com/datepicker/#option-beforeShowDay

@litvinenkow litvinenkow deleted the patch-1 branch April 15, 2014 11:01
@litvinenkow
Copy link
Author

@arschmitz, thank you for your widget and answer, could you please write some readme's?
it's unobvious that data-attributes of that kind is working and please explain how to use beforeShowDay or another native datepicker method with your widget
and how to change language?

@devsie
Copy link

devsie commented Apr 20, 2014

I'm a bit confused. I've been trying to get this datepicker working, but I'm having trouble adjusting the default date format.
Ideally I'd want dd-mm-yyyy. Changing 'dateFormat: "dd-mm-yyyy" ' on line 47 of jquery.mobile.datepicker.js hasn't worked for me.

I've tried the fix data-date-format="dd-mm-yyyy" (after finding it in a closed comment) and that has worked. But this would mean adjust that on every input and I really want to change the default settings.
Having tried @litvinenkow fix of "$.extend( $.datepicker._defaults, this.options );" this has worked. And yet I see you say this is not the correct solution.

So how can I adjust the default date format without using "$.extend( $.datepicker._defaults, this.options );" ?

@indrimuska
Copy link
Contributor

Look at #29 first.

#29 (comment)

@devsie
Copy link

devsie commented Apr 21, 2014

Hi,
I have read that. I'm sorry I must be missing something, I'm afraid I'm a novice.
It's not just the dateFormat, changing any of the options within the options:{ } of jquery.mobile.datepicker.js doesn't seem to affect the outcome on my test page.

@arschmitz
Copy link
Owner

There have been working examples of options shown and they have been tested and option setting works fine for both data format and others if you believe there is a bug we need to see a test page demonstrating your issue using the latest code from master. with out this i'm not sure how we can help you.

@indrimuska
Copy link
Contributor

@devsie if you use an external widget in you code, you have to treat it as a "library". In this way, you don't have to change the sources, you can just use all the methods the library provides to you. As I linked you, in #29 (comment) there are two solution to change options for all your inputs:

Good luck.

@devsie
Copy link

devsie commented Apr 21, 2014

@indrimuska Thank you. I had downloaded the code - jquery.mobile.datepicker.js to host it locally. (I understood that'd be faster).

I have followed your solution and used:
$.datepicker.setDefaults({dateFormat: "dd-mm-yy"});

However, may I ask, if it's not there to change the default settings, what is the purpose of 'dateFormat: "dd-mm-yyyy" ' on line 47 of jquery.mobile.datepicker.js?

@indrimuska
Copy link
Contributor

In the previous version of the wrapper, all default settings were in the widget options. In one of the last commit, arschmitz added the method _getCreateOptions which overrides all default options also contained in the ui-datepicker with the last ones (here) . Since dateFormat attribute is one of them, there's no need to maintain it in the default options (just because it will be overwritten).
That's why I open the pr #33.

@devsie
Copy link

devsie commented Apr 21, 2014

I fear it'll be a while before I fully comprehend. But thank you @indrimuska and @arschmitz for solving my issue and thank you for the wrapper/widget in general.

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

Successfully merging this pull request may close these issues.

4 participants