Note that there are some explanatory texts on larger screens.

plurals
  1. POKnockout Binding
    text
    copied!<p>I'm binding some list items to a dropdown through Knockout but it's not binding. I don't know where I am going wrong..</p> <p>I used the knockout mapping plugin and even tried a simple method but nothing seems to work.</p> <p>My basic structure is like this:</p> <pre><code>BugsReport rp = new BugsReport() { SoftwareProductList = new List&lt;SoftProduct&gt;() { new SoftProduct() { ProductName = "eCommerce Website", SoftProId = 1 }, new SoftProduct() { ProductName = "Banking website", SoftProId = 2 } }, ListBugs = GetAllBugs(), PriorityLevels = new List&lt;Priority&gt;() { new Priority() { PriorityId = 1, PriorityName = "P1" }, new Priority() { PriorityId = 2, PriorityName = "P2" }, new Priority() { PriorityId = 3, PriorityName = "P3" } } }; </code></pre> <p>which i am sending from controller... Normal razor binding is happening but not knockout.</p> <p>Html part</p> <pre><code>&lt;div style="margin-top: 10px; width: 200px; float: left; font-weight: bold;"&gt; Products &lt;select id="slSoftProducts" multiple="multiple" data-bind="options: $root.ProductList, value:ProductList.SoftProId, optionsText: 'ProductList.ProductName'"&gt;. &lt;/select&gt; &lt;/div&gt; &lt;div style="margin-top: 10px; width: 200px; float: left; font-weight: bold; margin-left: 30px;"&gt; priority Levels &lt;select id="slPriorityLevels" multiple="multiple" data-bind="options: $root.priorityList, value: priorityList.PriorityId, optionsText: 'priorityList.PriorityName'"&gt;&lt;/select&gt; &lt;/div&gt; </code></pre> <p>and Javascript part</p> <pre><code>function bugzillaviewmodel(){ var self = this; self.ProductList = BugList.SoftwareProductList; self.priorityList = BugList.PriorityLevels; } var viewModel = new bugzillaviewmodel(); // Knock Out Binding through mapping.. //var viewModel = ko.mapping.fromJS(BugList); ko.applyBindings(viewModel); </code></pre>
 

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