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

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -