I have just started learning KO. After creating a MVC4 project in VS 2012, I have just entered two text boxes in the view & expected to see the values getting reflected there, but its not working. Please help me fixing the defect in it...
The cshtml code is looks something like this...
NB : I have verified the KO path & version & found its correctly included.
@{
Layout = null;
}
@section scripts{
<script src="~/Scripts/jquery-1.7.1.js"></script>
<script src="~/Scripts/jquery-ui-1.8.20.js"></script>
<script src="~/Scripts/knockout-2.1.0.js"></script>
<script type="text/javascript">
$(function () {
var MyViewModel = {
name: ko.observable("Steve"),
changeName : function () {
this.name("Scott");
}
};
ko.applyBindings(MyViewModel);
});
</script>
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Create</title>
</head>
<body>
<div>
Name : <input type="text" data-bind="value: name " />
<p>
Hello, <span data-bind="text: name "></span>
</p>
<button data-bind="click: changeName">Change Name</button>
</div>
</body>
</html>