Bootstrap-datepicker: Add methods `getViewDate`, `setViewDate` to public api

Created on 16 Aug 2016  路  1Comment  路  Source: uxsolutions/bootstrap-datepicker

Would you accept a PR which adds getViewDate and setViewDate methods to public api? Implementation should follow defaultViewDate even so at least I didn't expected such a syntax.

So in detail I like to add this public api methods:

$().datepicker('getViewDate'); returns current viewDate as a plain object having keys year, month, day.

$().datepicker('setViewDate', { year: 2000, month: 0, day: 1 }); updates datepicker with view date ''1 January 2000''. If keys are missing they should default to the same as defaultViewDate. So $().datepicker('setViewDate', {}); would update datepicker with today as view date.

It's already possible to manipulate viewDate by using private api method _setDate with a Date object as first and 'view' as second parameter. So implementation is easily possible.

This new public api methods would allow implementing linked datepickers without using private api. Linked datepickers could be used to implement "showing multiple month" feature which is heavily requested (#1154 and many duplicates). I've written a proof of concept to show it's actually working: https://jsfiddle.net/v6q2rxs0/

getViewDate isn't really necessary therefore but should be added for consistency.

Would love to get some feedback before starting implementation.

Most helpful comment

Any updates on this?
This would be a really useful feature.

>All comments

Any updates on this?
This would be a really useful feature.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DHeinrichs picture DHeinrichs  路  5Comments

aifrim picture aifrim  路  5Comments

first-developer picture first-developer  路  6Comments

Erwane picture Erwane  路  6Comments

PlippiePlop picture PlippiePlop  路  6Comments