I am using a jquery date picker tool. But it is inside a v-if. When I toggle it on and off if I write this code it does not work.
showdatepicker:function(){
this.datepicker= true;
$(".jquery-date-picker").datepicker();
}
Because when $(".jquery-date-picker").datepicker(); runs vue still did not rendered html and added my datepicker input. But if change it to:
showdatepicker:function(){
this.datepicker= true;
setTimeout(function(){$(".jquery-date-picker").datepicker();},0);
}
It works. Because runs it after html render.
My question: is setTimeout a guaranteed way to do it after html render. Is there a proposed way in vuejs to do this right. I couldn't find any answer from my google and stackoverflow searches.