I am using knockback.js.I have a list of values "projects"(value comes from the server). and the content of these values are displayed in the <div class="hiddendivcontent">
.
<ul data-bind="foreach: projects" class="list-group">
<li class="list-group-item" data-bind="click: function(data,event){CommunityView.showContents($data.pkey(),$data.folder(), data, event);}">
<span style="border:0px;" class="glyphicon glyphicon-plus pull-right" data-toggle="dropdown" ></span>
<ul class="dropdown-menu labellistdropdown" role="menu" style="min-width:200px;">
<li>..</li>
</ul>
<div class="hiddendivcontent">
<ul data-bind= "foreach : $root.community()" class="list-group">
<ul data-bind = "foreach :items">
<li> <span data-bind="text:cname"></span></li>
</ul>
</ul>
</div>
</li>
</ul>
The "hiddendivcontent" gets the value when "CommunityView.showContents()" is clicked. In other words,"hiddendivcontent" should be displayed when the method is clicked otherwise it remains hidden. The following code is the Jquery code that i have used :
showContents : function(pk,rf,data,event){
event.preventDefault();
$('.hiddendivcontent').toggle();
}
If I use this above code the value is populated in all the list items. I have tried many ways to toggle the div but nothing works. Can anyone please suggest me any ideas?
Thanks in advance