0 Replies - 831 Views - Last Post: 21 May 2013 - 10:11 AM Rate Topic: -----

#1 ry110891  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 25
  • Joined: 24-May 12

Creating a view Model to add two integers?

Posted 21 May 2013 - 10:11 AM

I want to use Knockout JS and create a view model so that when you type integers in field one and two the output gets written to the answer element. Heres what I have:

<li><label>Field 1</label><input data-bind="value:fieldOne"/></li>
<li><label>Field 2</label><input data-bind="value:fieldTwo"/></li>
<li><label>Answer</label><div data-bind="text:answer"></div></li>

<script type="text/javascript">
function testViewModel()
{
this.fieldOne = ko.observable();
this.fieldTwo = ko.observable();
}
ko.applyBindings(new testViewModel());
</script>

Cam amyone help?

Is This A Good Question/Topic? 0
  • +

Page 1 of 1