Dependent Dependent Methods

by Trae

HTML

<script src="http://cdn.kendostatic.com/2014.3.1411/js/kendo.all.min.js"></script>
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1411/styles/kendo.common.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1411/styles/kendo.default.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1411/styles/kendo.mobile.all.min.css">
<div data-bind="source: data" data-template="tmp"></div>
<script id="tmp" type="text/x-kendo-template">
    <div>
        Quantity:<input data-role="numerictextbox" data-bind="value:quantity" /><br/>
        Price: <input data-role="numerictextbox" data-bind="value:price" /><br/>
        Total: <span data-bind="text: total"></span><br />
        Free Shipping:  <span data-bind="text: freeShipping"></span>
    </div>
</script>

JavaScript

var obj = {
       quantity: 1,
       price: 45,
       total: function () {
           return this.get("quantity") * this.get("price");
       },
       freeShipping: function () {
           return this.total() > 100;
       }
   };

   var viewModel = kendo.observable({
      data: obj
    });
   kendo.bind($(document.body), viewModel);