I want to show only first 2 things which are present in an array instead of all and then b y clicking on button next 2 names comes up till the last, but the code which I am trying is not working. I am giving the code please tell the bug. Can you help me in correcting the code of knoctout js .
In Javascript
EventBE.displayCount = ko.observable(2);
EventBE.readMore = function() { EventBE.displayCount(EventBE.displayCount() + 2); };
in html
div class="slide">
<button type="button" data-bind"click: EventBE.readMore,visible:
EventBE.displayCount() < EventBE.WhoElseAttends.length">Read More</button>
<ul data-bind="foreach:EventBE.WhoElseAttends.slice(0,
EventBE.displayCount())">
<li >
<span data-bind="text:FirstName"></span>
<span data-bind="text:LastName"></span>,
<span data-bind="text:Company"></span>
</li>
</ul>
<span data-bind="if:EventBE.WhoElseAttends.length <0">No Attendees</span>
</div>
Here's the working HTML:
And the accompanying Knockout view model:
I've also rendered this code in the following jfiddle: http://jsfiddle.net/Bg5CF/17/