Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET MVC4 and Knockout js
    primarykey
    data
    text
    <p>I am trying to use knockout js in my project so I tried the simple Hello World example but i couldnt get it to work. I created a new MVC4 project and just copy do a simple binding below is my code</p> <pre><code>&lt;script src="~/Scripts/knockout-2.1.0.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; // Here's my data model var viewModel = function (first, last) { this.firstName = ko.observable(first); this.lastName = ko.observable(last); //this.fullName = ko.computed(function () { // Knockout tracks dependencies automatically. It knows that fullName depends on firstName and lastName, because these get called when evaluating fullName. //return this.firstName() + " " + this.lastName(); //}, this); }; $(document).ready(function() { ko.applyBindings(new viewModel("Planet", "Earth")); // This makes Knockout get to work });​ &lt;/script&gt; &lt;div class="liveExample"&gt; &lt;p&gt;First name: &lt;input data-bind="value: firstName" /&gt;&lt;/p&gt; &lt;p&gt;Last name: &lt;input data-bind="value: lastName" /&gt;&lt;/p&gt; @*&lt;h2&gt;Hello, &lt;span data-bind='text: fullName'&gt; &lt;/span&gt;!&lt;/h2&gt;*@ &lt;/div&gt; </code></pre> <p>Basically it will just display the value of the model on a textbox. I already referenced the knockout.js in my project but it does not work I also added the knockout js in my BundleConfig.cs</p> <pre><code>bundles.Add(new ScriptBundle("~/bundles/knockout").Include("~/Scripts/knockout-2.1.0.js")); </code></pre> <p>I didnt work</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload