0
I am using Datepicker to set month and year as parameters for my search, for this I want to play them as a warning to be sure that they are being stored in the variable, but I can’t - I believe because I am in onClose function. If anyone knows how to help me, follow my code:
$( function() {
$( "#monthpicker" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'MM yy',
dateFormat: 'dd/mm/yy',
onClose: function (dateText, inst) {
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(year, month, 1));
alert(year, month);
},
dayNames: ['Domingo','Segunda','Terça','Quarta','Quinta','Sexta','Sábado','Domingo'],
dayNamesMin: ['D','S','T','Q','Q','S','S','D'],
dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb','Dom'],
monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'],
});
} );
Right, but how do you stop setting for a variable?
– Natan Hoffmann
var datepicker = $("#monthpicker"). datepicker("getDate"); If possible scores the response friend.
– Maycon F. Castro
Thanks Maycon, it worked!
– Natan Hoffmann