Hello,
we have a problem with some memory leaks using the kendo MVVM Pattern. I try to explain it based on the following class:
var
myClass = (
function
(_super) {
__extends(myClass, _super);
function
myClass(ctx, folder, options) {
_super.call(
this
, ctx, folder, options);
this
.containerRight =
null
;
this
.viewModelRight =
null
;
}
myClass.prototype.init =
function
() {
var
dfd = $.Deferred();
this
.buildMenu().done(dfd.resolve).fail(dfd.reject);
return
dfd.promise();
};
myClass.prototype.buildMenu =
function
() {
var
_this =
this
;
var
dfd = $.Deferred();
this
.containerRight =
this
.container.find(
".right"
);
this
.viewModelRight = { items:
new
kendo.data.ObservableArray([]) };
kendo.bind(
this
.containerRight, kendo.observable(
this
.viewModelRight));
var
selectViewViewModel = kendo.observable({
title:
"test"
,
iconSource:
"test"
,
iconStyle:
"top: -270px; left: -73px;"
,
dataSource: [],
selectedValue:
""
,
selected:
function
(e) {
_this.doSomething();
}
});
this
.viewModelRight.items.push(selectViewViewModel);
return
dfd.resolve();
};
myClass.prototype.doSomething =
function
() {
};
myClass.prototype.destroy =
function
() {
_super.prototype.destroy.call(
this
);
kendo.unbind(
this
.containerRight);
};
return
myClass;
})(vendor.Templates.TemplateBase);
The leak occures on
selected:
function
(e) {
_this.doSomething();
}
or on
selectViewViewModel.bind(
"selected"
,
function
() { _this.doSomething() });
//and
selectViewViewModel.bind(
"selected"
, _this.doSomething.bind(
this
));
Every access to a instancemethod or variable out of the viewmodel seams to cause a leak.
Directly in jQuery we could solve the problem with, but it has no impact on bindings within the kendo MVVM
something.bind(
"selected"
, _this.doSomething.bind(
this
));
Does someone know a solution for this problem?
Thanks in advance,
Michael