jQuery UI datepicker: getDate to prepend the selected date? -
i have ui datepicker, , tried onselect prepend date have chosen inside #viewcalender:
$(function() { $('#rangea').daterangepicker({ arrows: true, onclose: function(event) { $('#calenderview').prepend('ok!'); }, onselect: function(){ var day1 = $("#rangea").datepicker('getdate').getdate(); var month1 = $("#rangea").datepicker('getdate').getmonth() + 1; var year1 = $("#rangea").datepicker('getdate').getfullyear(); var fulldate = year1 + "-" + month1 + "-" + day1; $('#calenderview').prepend(fulldate); } }); });
but nothing happens when select date. wrong here?
onclose: function(){ var date = $(".range-start").datepicker('getdate'); var dateend = $(".range-end").datepicker('getdate'); if(date != null){ if(dateend != null){ var day2 = dateend.getdate(); var month2 = dateend.getdate(); var year2 = dateend.getdate(); var fulldate2 = year2 + "-" + month2 + "-" + day2; }else{ var fulldate2 = 0; } var day1 = date.getdate(); var month1 = date.getmonth() + 1; var year1 = date.getfullyear(); var fulldate = year1 + "-" + month1 + "-" + day1; $.ajax({ url: "misc/getcalender.php", type: "post", data: { datestart: fulldate, dateend: fulldate2 }, success: function(response){ alert('passed: ' + fulldate + ' - '+ fulldate2); } }); } }
instead of onselect
, the event onchange
, change code use option , should set. also, date isn't stored in #rangea
set of inputs creates, .range-start
, .range-end
respectively (yes...you can't have more 1 on page currently).
you can test here, note onchange
fires twice per selection...this shouldn't problem when you're using result replace value, instead of prepending (resulting in multiple prepends).
Comments
Post a Comment