Jquery map slow on binding with JSknockout
when am trying to map a semi large set of data I notice it is slow .. the
browser will even freeze for few seconds . I am not sure if it is from
Jquery map or the knockout
I think that this part where it slows
model.Entries($.map(data.Entries, function (e, i) { return new
FieldFormatEntry(e.Name, e.HasTransformationList,e.Caption, e.HeaderName,
e.Format, e.AcceptedFormats); }));
here is the code
function FieldFormatEntry(name,transformationList,caption, headerName,
format, acceptedFormats) {
var self = this;
self.Name = ko.observable(name);
self.Caption = ko.observable(caption);
self.HeaderName = ko.observable(headerName).extend({ required: true });
self.Format = ko.observable(format).extend({ required: true });
self.AcceptedFormats = ko.observableArray();
if (acceptedFormats !== null && acceptedFormats.length > 0)
{
var formats = ko.utils.arrayMap(acceptedFormats,function(item) {
return item;
});
self.AcceptedFormats.push.apply(self.AcceptedFormats, formats);
}`enter code here`
self.hasTransformationList = transformationList;
self.hasAcceptedFormatsList = ko.computed(function () {
return self.AcceptedFormats().length > 0;
}, this);
}
function dataSet() {
var self = this;
self.Entries = ko.observableArray();
self.showTip = ko.computed(function () {
return (self.Entries().length > 1);
}, this);
}
function fillAndBindEntries(data) {
var model = new dataSet();
model.Entries($.map(data.Entries, function (e, i) { return new
FieldFormatEntry(e.Name,
e.HasTransformationList,e.Caption, e.HeaderName, e.Format,
e.AcceptedFormats); }));
ko.applyBindings(model);
}
Any ideas ? how can I improve the performance
No comments:
Post a Comment