When trying to return the value of $("#datepicker-range").val()
at the beginning of the code, console
gives me an empty value. So I was suggested to do a page sniffer because the reason the field was not capturing the date field would be due to a problem in the order of operations on reading the code.
$(function(){
startSelectors();
var datepickerVerify = setInterval(function(){
if($("#datepicker-range").val()){
clearInterval(datepickerVerify);
var vl = $("#datepicker-range").val();
console.log('value returned: '+vl);
}
return vl;
}, 50);
//verificando o valor da variavel
console.log('datepicker=> '+datepickerVerify);
});
function startSelectors(){
$("#datepicker-range").val('2017-03-01 até 2017-08-02');
};
Instead of returning the date in the middle log, as it was returned inside if
, it returns me a true
(number 1). How can I set the value of the variable datepickerVerify
instead of the true
, to return the date?