0
<script language="javascript">
    var user = {"firstName":"Test","lastName":"Test Last"};
    var viewModel = ko.mapping.fromJS(user);  
    ko.applyBindings(viewModel);  
</script>

<input type="text" id="txtFName" data-bind="value: firstName" class="input-small" >
<input type="text" id="txtLName" data-bind="value: lastName" class="input-small">

But by some reason knockout doesn't show result on UI. What is can be ?

nemesv
  • 138,284
  • 16
  • 416
  • 359
Arbejdsglæde
  • 13,670
  • 26
  • 78
  • 144
  • 2
    Put the scipt tag under your inputs... and you should use `type="text/javascript"` instead of `language="Javascript"` see http://stackoverflow.com/questions/2267476/html-script-tag-type-or-language-or-omit-both – nemesv Mar 21 '13 at 15:01
  • Yes it is working thanks. What is the issue ? knockout with out mapping working well. – Arbejdsglæde Mar 21 '13 at 15:03

1 Answers1

1

Like nemesv says, you should use the following in your script block:

type="text/javascript"

Are you sure you have the correct references to knockout and knockout mapping? I created a jsfiddle based on your code which works fine:

http://jsfiddle.net/CUNWn/

Rune Vejen Petersen
  • 3,201
  • 2
  • 30
  • 46