breeze - Observable item has zero element in knockout Binding -


i running wired problem, record count of array 8 before , after applying custom binding, when debugging the binding array empty. since array empty grid not displaying anything. doing wrong?

var vm = {             recordscount: ko.observable(),             countries: ko.observablearray()         };         $(function () {          getallcountries();          // handler .ready() called.         //alert(myns.javascript1);         //alert(myns.javascript1);         //alert(myns.javascript2);      });       var servicename = "/breeze/countriesbreeze/";     var manager = new breeze.entitymanager(servicename);      /***  supporting functions ***/     function getallcountries() {         var query = breeze.entityquery.from("getcountries");         console.log("getting countries");         return manager.executequery(query)             .then(function(data) {                 vm.countries(data.results);                 alert(vm.countries().length);                 ko.applybindings(vm);                 alert(vm.countries().length);             }).fail(                 alert( "error getting data")             )     }   </script> <div id="log"></div> 

]

                   }">       </table> 

move ko.applybindings() statement here:

var vm = {             recordscount: ko.observable(),             countries: ko.observablearray()         };         $(function () {          getallcountries();          // handler .ready() called.         //alert(myns.javascript1);         //alert(myns.javascript1);         //alert(myns.javascript2);      });  ko.applybindings(vm); 

then i'm not sure if doing vm.countries(data.results) work, may need either iterate , push each value or do:

vm.countries(data.results) vm.countries.valuehasmutated() 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -