cchui
unread,Jan 10, 2012, 6:17:51 PM1/10/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to JavaScript Templates Engine PURE
Hi,
I've started using PURE and convince it's good way to make the code
much more organizable. I've used it to the extend that I need to
render a category tree in a non-tree UI. If it's just a tree UI
control, then the recursion example would help a lot.
Here I wanted to render the root level category as tabs, and then
showing the 2nd category items as sections in the tab content. And
then show the 3rd category items under each of the sections. The json
data would look like:
{"children0":[{"name":"A"},{"name":"B","children1":
[{"name":"B1","children2":[{"name":"B1a"},{"name":"B1b"}]}]},
{"name":"C"}]}
I use the jQuery UI tabs and therefore need to render the json with
this template.
dir: {
'li.tab-link': {
'child0 <- children0': {
'a': 'child0.pretty',
'a@href': '#tab#{child0.nodeId}'
}
},
'div.tab-content': {
'c0 <- children0': {
'.@id': 'tab#{c0.nodeId}',
'.': function(ctxt) {
return ctxt.c0.item.children1 ?
rfn(ctxt.c0.item):'';
}
}
},
'div.bar': {
'c1 <- children1': {
'a': 'c1.pretty'
}
}
}
The problem is when calling the rfn function for 'div.tab-content',
the render html for this function call includes both the whole root
and it's 2 directives underneath (excluded the 'div.tab-content' one.
However, I only want to render with the 'div.bar' inside the tab
content.
Does anyone knows who I can do this. Currently with the example
shown, the content has both the "<ul class='tab-link></ul><bar>B1a</
bar><bar>B1b</bar>". What I want to see in the content is just
"<bar>B1a</bar><bar>B1b</bar>".
Thanks,
Callistus