Note that there are some explanatory texts on larger screens.

plurals
  1. POunable to parse bindings for nested knockout bindings
    primarykey
    data
    text
    <p>I created two sub divs inside main div and based on radio button selection, div is shown and hidden. Now , inside one of the sub div i created one dropdown and used foreach binding to populate it.Now when i am running , list of items are coming but show and hide functionality stopped working and in console it is shown as "unable to parse binding" of foreach. Kindly help me in resolving the issue. sample code is present below :</p> <p><strong>HTML FILE</strong></p> <pre><code>&lt;body&gt; &lt;div id="selectdiv"&gt; &lt;input type="radio" id="radio1" name="radioGrp" /&gt;div1 &lt;input type="radio" id="radio2" name="radioGrp" /&gt;div2 &lt;/div&gt; &lt;div id="myDiv" name="myDiv" class="myDiv" style="font-family: Helvetica; font-size: 12pt; border: 1px solid black;"&gt; &lt;div id="subDiv1" name="subDiv1" data-bind="visible:subDiv1" class="subDiv1" style="color: #FF0000; border: 1px dotted black;"&gt; &lt;h5&gt;Section 1&lt;/h5&gt; &lt;p&gt;MONTHS...&lt;/p&gt; &lt;div id="tabContainer"&gt; &lt;ul data-bind="foreach: months"&gt; &lt;li&gt; &lt;b data-bind="text: $data"&gt;&lt;/b&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;br /&gt; &lt;div id="subDiv2" name="subDiv2" data-bind="visible:subDiv2" class="subDiv2" style="color: #FF00FF;border: 1px dashed black;"&gt; &lt;h5&gt;Section 2&lt;/h5&gt; &lt;p&gt;This paragraph would be your content paragraph...&lt;/p&gt; &lt;p&gt;Here's another content article right here.&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p><strong>JS FILE</strong></p> <pre><code>$(document).ready(function() { alert("ready"); var divdispalyViewModel1 = { subDiv1: ko.observable(true) }; var divdispalyViewModel2 = { subDiv2: ko.observable(true) }; ko.applyBindings({ months:[ 'Jan', 'Feb', 'Mar', 'etc' ] }); // alert("ready2"); ko.applyBindings(divdispalyViewModel1); ko.applyBindings(divdispalyViewModel2); $('#radio1').click(function () { alert("radio 1"); divdispalyViewModel1.subDiv1(true); divdispalyViewModel2.subDiv2(false); }); $('#radio2').click(function () { alert("radio2"); divdispalyViewModel1.subDiv1(false); divdispalyViewModel2.subDiv2(true); }); }); </code></pre> <hr> <pre><code>Month list is fetched from method present in second javascript but how html will get to know that month is binded to second javascript...i mean to say, suppose my first javascript is like below : $(document).ready(function() { alert("ready"); var vm = function () { var self = this; self.subDiv1 = ko.observable(false); self.subDiv2 = ko.observable(false); var subDemoMainObj=new subDemoMain(); subDemoMainObj.getMonths(); //self.months = ko.observableArray(['Jan', 'Feb', 'Mar', 'etc']); }; ko.applyBindings(new vm()); ko.applyBindings(subDemoMainObj, $('#tabContainer')[0]); }); Second javascript is as below function(ko){ alert("ready1"); var getMonths = function () { var self = this; self.months = ko.observableArray(['Jan', 'Feb', 'Mar', 'etc']); }; // alert("ready2"); //ko.applyBindings(new getMonths());`enter code here` }, i am expecting something like this but not understanding where i am going wrong :( :( </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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