Knockout & jQuery takes a VERY long time using push...
Hi all,
I am using jQuery and Knockout on my webapp, but when I try to process an array (~400 elements) the request can take a very long time to execute (around 60s!)
I've had to change some code and add a call to some dummy data (over 400 records: http://jsbin.com/futoze/1.json) . This runs in about a couple of seconds. Is there anything more complicated to your actual data than what you see here?
Hi,
Thanks for the suggestions...
I had applied the bindings.
The SCRIPT tag was inherited from the previous developer :-) It appears that as this form was previously used for multiple reports, they used the ID of the SCRIPT to run the appropriate section. Not needed anymore now so I'll remove it.
I do believe however that I have identified the issue... well, I have fixed the delay anyway...
As the "AppViewModel.page_model.my_log_entries" is an observable object, each time an entry is added to it, it is reevaluated. Looks like this takes some time in an array this time (quite why it is 60s I don't know!)
However, I have applied the 'pausable' extension to knockout: https://github.com/Areson/Knockout-Extensions/wiki/Knockout.Pausable
and it seems to be resolved. Now takes a fraction of a second to process:
AppViewModel.page_model.my_log_entries.pause();$.each(o.ajaxdata.ListOfEntries, function (key, val){ AppViewModel.page_model.my_log_entries.push(val);});AppViewModel.page_model.my_log_entries.resume();
i.e. "ko.applyBindings(AppViewM