Bootstrap Datetimepicker change event is not firing

家住魔仙堡 提交于 2021-02-07 14:16:57

问题


Bootstrap Datetimepicker change event is not firing without errors. Any clue?

https://github.com/Eonasdan/bootstrap-datetimepicker/blob/master/docs/Events.md

$('#datetimepickerStart').datetimepicker();

$('#datetimepickerStart').datetimepicker().on('change', function (ev) {
                alert('!!!');

});

回答1:


I found the solution

  $('#datetimepickerStart').datetimepicker().on('dp.change', function (event) {
                alert('!!!');
            });



回答2:


<div class="input-group date" id="dateOfBirth" data-target-input="nearest">
    <input type="text" class="form-control datetimepicker-input"
        data-target="#dateOfBirth" placeholder="Select DOB.." />
    <div class="input-group-append" data-target="#dateOfBirth"
        data-toggle="datetimepicker">
        <div class="input-group-text"> <i class="fa fa-calendar"> </i>
        </div>
    </div>
</div>



$("#dateOfBirth").on("change.datetimepicker", ({date}) => {
    var dob = $("#dateOfBirth").find("input").val();
    console.log(dob);
})

This worked for me.



来源:https://stackoverflow.com/questions/38744905/bootstrap-datetimepicker-change-event-is-not-firing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!