Iam using daterange picker plugin with stimulus js. Everything works fine, the issue is I have to call change function whenever I change the date in the date picker, but I can't able to call the action function (this.action) in stimulus js. Since stimulus js function can't able to access inside the onchange of the date picker.
$('input[name="daterange"]').daterangepicker({
opens: 'left',
startDate: start,
endDate: end,
ranges: {
'Today': [moment(), moment()],
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')],
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
},
maxDate:parseInt(moment().subtract(30, 'days'), moment()),
locale: {
format: 'MMM DD, YYYY '
},
}).on('apply.daterangepicker', function(e, picker) {
this.startDate= moment($("input[name='daterange']").data('daterangepicker').startDate._d).format('YYYY-MM-DD');
this.endDate=moment($("input[name='daterange']").data('daterangepicker').endDate._d).format('YYYY-MM-DD');
this.onDateChange()//throws error
});
onDateChange(){
alert("date")
}