Assuming that the solution should only work in the latest versions of Chrome, Firefox and Safari as a bonus.
-
I am trying to use an associative array for a large dataset with a knockout. My first attempt made it a true associative array:
[1: {Object}, 3: {Object},...,n:{Object}]
but the knockout was unhappy with the cycle of this. So I tried to trick, hoping that:
[undefined, {Object}, undefined, {Object},...,{Object}]
where in the array is the PK identifier from the database table. This array has a size of about 3.2 thousand Elements, and it will be repeated approximately every 10 seconds, therefore, speed is required. I tried to do this with a splice, for example.
$.each(data, function (index, item) {
self.myArray.splice(item.PKID, 0, new Object(item));
}
, , PKID 1, myArray[0] . PK 500, 0 .
- var myArray = new Array(maxSize), . - , , javascript.
, , , - . , , , . , , , .
, , ? DOM , , , , 10 . , -.
-
:
( new Array(maxLength), 10 , , . , .
-
:
<div class="tile" data-bind="attr: {id: 'tileID' + $data.PKID()}">
<div class="content">
</div>
</div>
:
$.each(data.Updated, function (index, item) {
var obj = myModel.myArray()[item.PKID];
}