0

html li in template

asked 2023-01-29 09:01:12 +0800

agsiegel gravatar image agsiegel
6 1

updated 2023-01-29 09:03:34 +0800

Is it possible to use a template with a <ul> html tag?

<n:ul children="@load(vm.items)">
  <template name="children" var="each">
    <n:li>${each}</n:li>
  </template>
</n:ul>

This does not work. But I want to do this exactly.

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-02-01 10:10:15 +0800

hawk gravatar image hawk
3250 1 5
http://hawkphoenix.blogsp... ZK Team

updated 2023-02-01 10:18:44 +0800

If your prefix n mean zk 'native' namespace, then native HTML tags don't support data binding. See https://www.zkoss.org/wiki/ZKDeveloper%27sReference/UIPatterns/HTMLTags

You can replace it with xhtml component set or <forEach>:

<zk xmlns:n="native" xmlns:x="xhtml">
    <zscript><![CDATA[
    ListModelList items = new ListModelList();
    items.add("a");
    items.add("b");
    ]]></zscript>
    <div apply="org.zkoss.bind.BindComposer">
        <x:ul children="@load(items)">
            <template name="children">
                <n:li>${each}</n:li>
            </template>
        </x:ul>
        <!-- native with forEach   -->
            <n:ul>
                <forEach items="@init(items)">
                    <n:li>${each}</n:li>
                </forEach>
            </n:ul>
    </div>
</zk>
link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2023-01-29 09:01:12 +0800

Seen: 6 times

Last updated: Feb 01 '23

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More