pwt.datepicker
pwt.datepicker copied to clipboard
Event should be removed after destroy
We need load multiple field for date and time picking in many times. After some work we destroy all of them and again create new field(with other id) but after few times date picker load slower and popups work slower than first time used.
I test it and find problem was for events of last created fields. we should unbind events from destroyed fields.
I use this method for remove events:
onDestroy: function() {
var ElemID = this.model.view.id;
var Elem = this.elem;
$("#" + ElemID).off();
$("#" + Elem).off();
$(document).off("click", "#" + ElemID + " .pwt-btn-today");
$(document).off("click", "#" + ElemID + " .pwt-btn-calendar");
$(document).off("click", "#" + ElemID + " .pwt-btn-submit");
$(document).off("click", "#" + ElemID + " .pwt-btn");
$(document).off("click", "#" + ElemID + " .up-btn");
$(document).off("click", "#" + ElemID + " .down-btn");
$(document).off("click", "#" + ElemID + " .datepicker-day-view td:not(.disabled)");
$(document).off("click", "#" + ElemID + " .datepicker-month-view .month-item:not(.month-item-disable)");
$(document).off("click", "#" + ElemID + " .datepicker-year-view .year-item:not(.year-item-disable)");
}
if this type is fully covered unbind events, please fix that in core of persianDatepicker. thank you
@firstboy000 thanks, could you make a pull request from your solution?