I'm using bootstrap date time picker in my project and I need to listen the change of a input tag in order to modify the value of a second one. I tried to liste to it with vanilla Js, jQuery and even Stimulus.js without success. I can properly listen the click event but the change doesn't work.
Here's my picker with some of attempts to listen the change event:
$('.datetimepicker').datetimepicker({
format: 'LT',
locale: 'PT-BR',
icons: {
up: "fa fa-chevron-up",
down: "fa fa-chevron-down",
time: "far fa-clock",
},
enabledHours: permittedHours(),
stepping: 15,
})
Vanilla:
const handleHourStart = () => {
let hourStart = document.getElementById('order_hour_start');
hourStart.addEventListener('input', () => {
alert('CHANGED!');
})
}
jQuery:
$(document).ready(function(){
$("#order_hour_start").change(function(){
alert($(this).val());
});
});
Stimulus.js
import { Controller } from "stimulus"
export default class extends Controller {
static targets = [ 'hour_start', 'hour_finish' ];
connect() {
console.log(this.hour_startTarget);
}
update() {
alert('Changed');
}
}
All they responds well to the click event, but doesn't for change...
I really don't know how to manage it with the picker functions, the docs are very confused to me...