jdewit / bootstrap-timepicker

[Deprecated] A simple timepicker component for Twitter Bootstrap
MIT License
1.64k stars 1.09k forks source link

reset/remove/destroy element binded with timepiker 2021 and BS4 #394

Open arcanisgk opened 3 years ago

arcanisgk commented 3 years ago

if any is working with this library and need reset/remove/destroy element binded with timepiker and not work correctly, i have done with this:

var date1 = $('[name="i_hou_1"]'); //input related to timepicker
var date1div = date1.closest(".input-group.bootstrap-timepicker.time");  //input-addon related to timepicker (class can variate)

window.DatepickersDestroy(date2div); //global call to the method

function TimePickerDestroy(target) {
    target.find("input:text").each(function () {
        var picker = $(this);
        picker.timepicker('remove');
        picker.off('click');
    });
    target.find("*").each(function () {
        var picker = $(this);
        picker.off('click');
        picker.off('.timepicker');
    })
}