I've been working with adding some custom binders, via typescript, to our project. All of the examples show that overriding the 'init' function is how I am supposed to parse attributes from the elements into (e.g.) custom properties. The issue I'm having is that the overridden 'init' function *never* seems to be called. If I switch to overriding the constructor, instead of init, this works as expected.
My question is - am I doing this incorrectly, is there anything inherently wrong with overriding the constructor itself, and *why* doesn't the override on init actually fire? I've tried this several ways, at this point I'm exactly duplicating the structure from kendo.d.ts, going with the assumption that the override might not fire if typescript doesn't see an exact match.
Again, note that the below extension is working - BUT if I were to remove the constructor override, the init override would never be called (confirmed via multiple debugging attempts).
module kendo.data.binders {
export class date extends kendo.data.Binder {
dateformat: string = "d";
constructor(element: any, bindings: Bindings, options?: BinderOptions) {
//call the base constructor
super(element, bindings, options);
this.dateformat = $(element).data("dateformat");
}
//Note: this NEVER seems to be called
init(element: any, bindings: Bindings, options?: BinderOptions): void {
//call the base constructor
kendo.data.Binder.fn.init.call(this, element, bindings, options);
this.dateformat = $(element).data("dateformat");
}
refresh() {
var data = this.bindings["date"].get();
if (data) {
var dateObj = new Date(data);
$(this.element).text(kendo.toString(dateObj, this.dateformat));
}
}
}
}