Help on Knockout js dynamic template.

114 views
Skip to first unread message

john genaro

unread,
Feb 18, 2013, 9:30:12 PM2/18/13
to knock...@googlegroups.com, johnpma...@yahoo.com, jo...@opusgrid.com
Hi Everyone,

I very new into using Knockout JS.. Just recently I stumbled on using the Knockout js template.

My question is, is it possible to set dynamic templating in knockout.

Please see scenario belo..

<!--
EXAMPLE NUMBER 1.

Number of li inside ul is 2.
-->

<div>
<ul>
<li>
</li>
<li>
</li>
</ul>
<ul>
<li>
</li>
<li>
</li>
</ul>
</div>


<!--
EXAMPLE NUMBER 2.

Number of li inside ul is 3. 
-->

<div>
<ul>
<li>
</li>
<li>
</li>
<li>
</li>
</ul>
<ul>
<li>
</li>
<li>
</li>
<li>
</li>
</ul>
</div>



<!--

The number of LI inside UL is dynamically set, it could be 2 or 3 or 4 etc etc..

-->

Thanks
John

Omar Abou Mrad

unread,
Feb 19, 2013, 6:01:33 AM2/19/13
to knock...@googlegroups.com, johnpma...@yahoo.com, jo...@opusgrid.com


On Tuesday, February 19, 2013 4:30:12 AM UTC+2, john genaro wrote:
Hi Everyone,

I very new into using Knockout JS.. Just recently I stumbled on using the Knockout js template.

My question is, is it possible to set dynamic templating in knockout.

Please see scenario belo..
<snip>

 john,

It would be better if you think about the content of those LI, rather than thinking about the number of LI. What does your UL represent? a list of people names?





john genaro

unread,
Feb 19, 2013, 9:56:20 AM2/19/13
to knock...@googlegroups.com, johnpma...@yahoo.com, jo...@opusgrid.com
Thanks for your response Omar, my UL represents are list of names. However, what I would like to achieved is that when the window is resize, the number of li should increase, otherwise, it should decrease.


Noong Martes, Pebrero 19 2013 03:01:33 UTC-8, si Omar Abou Mrad ay sumulat:

Casey Corcoran

unread,
Feb 20, 2013, 10:06:52 AM2/20/13
to knock...@googlegroups.com
I would just use a foreach binding with a computed to filter a source array, like:


Casey Corcoran
--
You received this message because you are subscribed to the Google Groups "KnockoutJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knockoutjs+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages