datedDisabled on changeMonth and on show not working
See original GitHub issueExpected behaviour
I want to disable date via loading by ajax. When datepicker onpens and month changed it must setDisabledDates from loaded array
Actual behaviour
I tryed set it by show and changeMonth event, but i did’t find any example how to make it. Please help me to solve this problem
Datepicker version used
v1.7.0-dev
Example code
var array = new Array();
function load_reservation(stock, year = null, month = null, callback){
jQuery.ajax({
method: "POST",
url: "'.Url::to(['site/ajax-load-reservation']).'",
data: { "stock": stock, "year": year, "month": month },
success: function(data) {
if(data.result==1){
callback(data.array);
}
else callback(null);
},
dataType: "json",
async: false
});
}
$(".book").each(function(){
var id = $(this).attr("data-stock_id");
load_reservation(id, null, null, function(result){
array[id] = result;
console.log("Loaded dates for #"+ id +": "+array[id]);
});
});
$(".book").datepicker({
multidate: true,
startDate: "1d",
language: "ru",
format: "yyyy-mm-dd",
}).on("click", function(e){
var id = $(this).attr("data-stock_id");
e.datesDisabled = array[id];
}).on("changeMonth", function(e) {
var id = $(this).attr("data-stock_id");
var year = e.date.getFullYear();
var month = e.date.getMonth() + 1;
load_reservation(id, year, month, function(result){
array[id] = result;
console.log("Onchange Loaded dates for #"+ id +": "+array[id]);
});
setDatesDisabled = array[id];
console.log(e);
return e;
});
Jsfiddle example to reproduce the problem.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
bootstrap-datepicker: changeMonth returns different date ...
I appears that by clicking a date the date is changed by that actual date click, rather than by the month change. The...
Read more >jQuery UI DatePicker - Tips and Tricks - DotNetCurry.com
We are setting the individual configurable options as follows: changeMonth: true to show the month change dropdown; changeYear: true to show the ...
Read more >jQuery UI Datepicker changeMonth option - GeeksforGeeks
jQuery UI Datepickers widget allow users to enter dates easily and visually. In this article, we will see how to use changeMonth option...
Read more >Datepicker not working when Qualtrics validation failed (Force ...
But after that when I click on the datepicker textbox datepicker stop functioning (i.e. calendar is not showing).
Read more >Jquery datepicker changemonth not working what to do?
have tried this simple code, it works as expected <html lang="en"> <head> <link rel="stylesheet" ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@asarapas What you are facing is a known and confirmed bug in bootstrap-datepicker: #2054 You could avoid the bug if you set
updateViewDate
option tofalse
or write a work-a-round that updatesviewDate
by using private api (#1978) after you calledsetDatesDisabled
.Of course you could also write an PR that fixes the bug in bootstrap-datepicker. 😃
I’m not sure there is any implementation we could do in our side for ajax loading. There’s a snippet that should works well in your case: