I have stucked with this problem. The datepicker is working fine on static content.
But fails when content is loaded via Ajax.
I Have tried :-
jQuery.noConflict();
jQuery(function($) {
$(document).ready(function(){
$( ".datepickerRange" ).datepicker({
dateFormat: 'dd-mm-yy',
prevText:'',
nextText:'',
minDate: 0,
maxDate: "+1M",
showOn: "button",
buttonImage: divadatepicker.image_url+"/calendar.jpeg",
buttonImageOnly: true
});
$( ".datepicker" ).datepicker({
dateFormat: 'dd-mm-yy',
prevText:'',
nextText:'',
showOn: "button",
buttonImage: divadatepicker.image_url+"/calendar.jpeg",
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
yearRange: "1960:2015"
});
});
$(document).live(function(){
$( ".datepickerRange" ).datepicker({
dateFormat: 'dd-mm-yy',
prevText:'',
nextText:'',
minDate: 0,
maxDate: "+1M",
showOn: "button",
buttonImage: divadatepicker.image_url+"/calendar.jpeg",
buttonImageOnly: true
});
$( ".datepicker" ).datepicker({
dateFormat: 'dd-mm-yy',
prevText:'',
nextText:'',
showOn: "button",
buttonImage: divadatepicker.image_url+"/calendar.jpeg",
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
yearRange: "1960:2015"
});
});
});
It is not showing the even calender small image after content loaded via ajax.
Call .datepicker
in your success
callback function on your ajax call instead of using .live
, which is deprecated. Example:
function initdatepicker(){
$( ".datepickerRange" ).datepicker({
dateFormat: 'dd-mm-yy',
prevText:'',
nextText:'',
minDate: 0,
maxDate: "+1M",
showOn: "button",
buttonImage: divadatepicker.image_url+"/calendar.jpeg",
buttonImageOnly: true
});
$( ".datepicker" ).datepicker({
dateFormat: 'dd-mm-yy',
prevText:'',
nextText:'',
showOn: "button",
buttonImage: divadatepicker.image_url+"/calendar.jpeg",
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
yearRange: "1960:2015"
});
}
$(document).ready(function(){
initdatepicker();
});
And add this to your $.ajax
success
:
initdatepicker();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With