javascript - Knockout update observable -
i extending application knockout.js set want dynamically display file upload. code
function search() { var self = this; //many different items set self.totalsize = ko.observable(total); self.uploadedsize = ko.observable(uploaded); } var uploadprogress; var total = 100; var uploaded = 0; function runuploadprogress() { uploadprogress = setinterval(function () { callwebapi({ api: webapi.getuploadprogress, data: null, cache: false, success: function (json) { total = json.totalbytes; uploaded = json.transferedbytes; console.log(total + " - " + uploaded); } }); if (total == uploaded) { stopuploadprogress(); } }, 1000); return true; } function stopuploadprogress() { clearinterval(uploadprogress); }
how can make totalsize , uploadedsize observable update new values? thought if change value of total , uploaded change value in observables?
after creating observable have change observable value with
searchinstance.totalsize(json.totalbytes); searchinstance.uploadedszie(json.transferedbytes);
Comments
Post a Comment