CSS bindings: How to repeat element and change both attribute & content

182 views
Skip to first unread message

Jeppe Nejsum Madsen

unread,
Jan 4, 2011, 7:06:14 AM1/4/11
to lif...@googlegroups.com
Hi,

I have a template like this:

<tr class="leasing_company">
<td class="row-labels name">lc name</td>
<td class="values">123</td>
</tr>


I need the tr's to repeat and within the structure, the last td
element to repeat with content but also with a specific class
attribute.

The last bit seems to cause some problems:

I have this:

".name *" #> lc.name.is &
".values *" #> res.segments.map {segment =>
res.filteredResult(lc).avg(segment).toString}

which will handle the td with content, but how do also add a
(calculated) class attribute to the td?

/Jeppe

David Pollak

unread,
Jan 4, 2011, 8:48:59 AM1/4/11
to lif...@googlegroups.com
On Tue, Jan 4, 2011 at 4:06 AM, Jeppe Nejsum Madsen <je...@ingolfs.dk> wrote:
Hi,

I have a template like this:

        <tr class="leasing_company">
             <td class="row-labels name">lc name</td>
             <td class="values">123</td>
        </tr>


I need the tr's to repeat and within the structure, the last td
element to repeat with content but also with a specific class
attribute.

The last bit seems to cause some problems:

I have this:

".name *" #> lc.name.is &
".values *" #> res.segments.map {segment =>
res.filteredResult(lc).avg(segment).toString}

".values" #> things.map {
  case x if x.last => "* *" #> x.toString & "* [class+]" #> "last"
  case x => "* *" #> x.toString
}
 

which will handle the td with content, but how do also add a
(calculated) class attribute to the td?

/Jeppe

--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.




--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Blog: http://goodstuff.im
Surf the harmonics

Jeppe Nejsum Madsen

unread,
Jan 4, 2011, 9:17:01 AM1/4/11
to lif...@googlegroups.com
On Tue, Jan 4, 2011 at 2:48 PM, David Pollak
<feeder.of...@gmail.com> wrote:
>
>
> On Tue, Jan 4, 2011 at 4:06 AM, Jeppe Nejsum Madsen <je...@ingolfs.dk>
> wrote:
>>
>> Hi,
>>
>> I have a template like this:
>>
>>         <tr class="leasing_company">
>>              <td class="row-labels name">lc name</td>
>>              <td class="values">123</td>
>>         </tr>
>>
>>
>> I need the tr's to repeat and within the structure, the last td
>> element to repeat with content but also with a specific class
>> attribute.
>>
>> The last bit seems to cause some problems:
>>
>> I have this:
>>
>> ".name *" #> lc.name.is &
>> ".values *" #> res.segments.map {segment =>
>> res.filteredResult(lc).avg(segment).toString}
>
> ".values" #> things.map {
>   case x if x.last => "* *" #> x.toString & "* [class+]" #> "last"
>   case x => "* *" #> x.toString
> }
>

Thanks, works great! I've updated the Wiki with this example and the
"*" selector.....

The CSS binding stuff is both neat and very powerful, but I feel I
lack a good reference as to what is possible (maybe this was the only
one missing from the Wiki, in which case everything is fine :-) The
amount of implicits at work to make this happen makes it less than
trivial to peruse the source....

/Jeppe

David Pollak

unread,
Jan 4, 2011, 9:21:39 AM1/4/11
to lif...@googlegroups.com

I think a lot of material for a good reference on CSS Selector Transforms will come from today's training.

I've been keeping the facts up to date here: http://stable.simply.liftweb.net/#sec:CSS-Selector-Transforms

I expect there will be a bunch of CSS Select Transform recipes that make it into Simply Lift.
 

/Jeppe

--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.

Jeppe Nejsum Madsen

unread,
Jan 4, 2011, 9:27:20 AM1/4/11
to lif...@googlegroups.com
On Tue, Jan 4, 2011 at 3:21 PM, David Pollak

Ahh cool. Haven't had time to dig into Simply Lift yet....seems like
it could be worthwile :-)

/Jeppe

Reply all
Reply to author
Forward
0 new messages