Displaying selected tab

2 views
Skip to first unread message

Sean

unread,
Mar 9, 2010, 10:53:18 AM3/9/10
to Spark View Engine Dev
I have two levels of tabs at the top of my application -- a root level
and then a sub tab this is laid out via two unordered lists something
like

Root Level Tabs
<li class="selected">Fruit</li> - (current and selected)
<li> Vegetables</li>

Second level tabs based on selection from the Root Level
<li class="selected">Oranges</li>
<li> Apples</li>
<li> Bananas</li>

Im not sure how to mark these as selected based on the context of the
application for instance if Im on the Oranges List view of the fruit
tab and I click add new I need the fruit tab and the oranges tab to
have the "selected" appearance on the "orange" edit view

I came up with a somewhat crazy way of doing this with CSS and
assigning an ID to the body tag via a spark global -- then on every
page/view I have to assign that BodyId then via css cascades show the
tabs selected based on matching the bodyid and the tabid

Is that completely confusing?

Bruno Windels

unread,
Mar 9, 2010, 11:09:48 AM3/9/10
to spar...@googlegroups.com
There might be a cleaner way than this, but I just do it with some inline code (comparing to an enum value if you only have a limited set of tabs):

<ul>
<li${currentFruit==Fruit.Oranges?" class=\"selected\"":""}>Oranges</li>
<li${currentFruit==Fruit.Apples?" class=\"selected\"":""}>Apples</li>
</ul>

I didn't really get your current way of doing things, but this seems simpler.


2010/3/9 Sean <seanm...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Spark View Engine Dev" group.
To post to this group, send email to spar...@googlegroups.com.
To unsubscribe from this group, send email to spark-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spark-dev?hl=en.




--
Bruno Windels
Ingeniero Software
bwin...@innopulse.es
www.innopulse.es

Tel.   (+34) 911.427.887
Móv. (+34) 608.100.715
Fax   (+34) 917.710.826
C/. Aguacate, 29, 2-3, 28044 MADRID





"La información contenida en este mensaje de e-mail es privada y confidencial, destinada solamente para el uso de la persona o entidad arriba indicada.
Si el receptor de este mensaje no es el destinatario mencionado, se le comunica que cualquier uso, difusión, distribución o reproducción de cualquier tipo está estrictamente prohibida y deberá proceder a su devolución o destrucción.”

Louis DeJardin

unread,
Mar 9, 2010, 6:37:52 PM3/9/10
to spar...@googlegroups.com

<ul>
<li class="selected?{currentFruit==Fruit.Oranges}">Oranges</li>
<li class="selected?{currentFruit==Fruit.Applies}">Apples</li>
</ul>

Louis DeJardin

unread,
Mar 9, 2010, 6:38:41 PM3/9/10
to spar...@googlegroups.com
(Sorry - forgot to add text)
 
You could also use the conditional attrib ?{ } syntax

Bruno Windels

unread,
Mar 10, 2010, 4:24:52 AM3/10/10
to spar...@googlegroups.com
That's pretty cool actually! Didn't know about that

Thanks

2010/3/10 Louis DeJardin <louis.d...@gmail.com>
Reply all
Reply to author
Forward
0 new messages