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
year, year-month, year-month-day picker possibilities #145
Comments
+1 |
I think I have a nice solution: $('.monthpicker').datepicker({
"format": "yyyy-mm",
'startView': 1
}).on('changeMonth', function(e) {
var dp = $(e.currentTarget).data('datepicker');
dp.date = e.date;
dp.setValue();
dp.hide();
});
$('.yearpicker').datepicker({
"format": "yyyy",
'startView': 2
}).on('changeYear', function(e) {
var dp = $(e.currentTarget).data('datepicker');
dp.date = e.date;
dp.setValue();
dp.hide();
}); |
@bartoszkopinski very nice! :) |
Great! Thank you, I was stuck trying to dismiss the picker and update the value on month change. 👍 |
Latest datepicker has |
Hi, this solution is very good for selecting only yyyy-mm format, but if you need to change the selected month when you click again it show the month viewmode. |
@sidronsile 添加一个配置项即可: {minViewMode: 1},this is my solution: |
its not working |
Hi,
If we are using minViewMode for range, then i need to select from January - 1st to March - 31st. And not March 1st as it would select now. Is there any option to change the selected date when using minViewMode? |
Given the way current datepicker is implemented. Its possible to have year picker, year-month picker along with the current date picker alone.
I've tried to do it automatically with parseDate, but didn't had success. So, this alternative version.
diff against current version is https://gist.github.com/3169847
Here is the code which shows the picker in action
<!doctype html>
<html>
<head>
<meta charset='utf-8'>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="bootstrap-datepicker.js"></script>
<link rel="stylesheet" href="bootstrap.2.0.4.css">
<link rel="stylesheet" type="text/css" href="datepicker.css">
</head>
<body>
<div class="container">
<form class="form form-horizontal">
<input type="text" id="a" date-date-format="dd/mm/yyyy"/>
<input type="text" id="b" date-date-format="mm/yyyy"/>
<input type="text" id="c" date-date-format="yyyy"/>
</form>
</div>
<script type="text/javascript">
$('#a').datepicker({startView : 'month', format : 'dd/mm/yyyy', enableYearToMonth: true, enableMonthToDay : true});
$('#b').datepicker({startView : 'year', format : 'mm/yyyy', enableYearToMonth: true, enableMonthToDay : false});
$('#c').datepicker({startView : 'decade', format : 'yyyy', enableYearToMonth : false, enableMonthToDay : false,});
</script>
</body>
</html>
The text was updated successfully, but these errors were encountered: