2012-03-08 17 views

答えて

3

quantityプロパティを間違って設定しています。 quantityko observableあるので、次の構文を使用する必要があります。

 self.sellIt = function (product) { 
      $.post('/Product/SellIt', { id: product.id }, 
      function (data) { 
       var res = Enumerable.From(self.products) 
          .Where("i => i.id == " + data.Id) 
          .Select("s => s"); 

       res.quantity(data.Quantity); // this is the important bit!! 
      }); 
     }; 

しかし、私はあなたがおそらくダウンだけにあなたのコードを短縮することができると思う:

 self.sellIt = function (product) { 
      $.post('/Product/SellIt', { id: product.id }, 
      function (data) { 
       product.quantity(data.Quantity); 
      }); 
     }; 
関連する問題