I'm exploring the new CSS selector binding functionality and must say
that it rocks!
One thing I can't seem to figure out:
I need to bind lists but also supply different attributes for each
item in the list.
E.g I want to end up with this:
<tr valign="top">
<td align="right" class="fieldname" style="width: 30%;" />
<td id="header" class="weekday" style="width: 10%">Ma 25-10</td>
<td class="weekday clearable" style="width: 10%">Ti 26-10</td>
<td class="weekday clearable" style="width: 10%">On 27-10</td>
<td class="weekday clearable" style="width: 10%">To 28-10</td>
<td class="weekday clearable" style="width: 10%">Fr 29-10</td>
<td class="weekend clearable" style="width: 10%">Lø 30-10</td>
<td class="weekend clearable" style="width: 10%">Sø 31-10</td>
</tr>
Note the different classes on the td elements. If I do
"#header *" #> plan.dates.map {_.toString}
they all get the weekday class.
Any way to solve this (besides moving the bind up to the tr and
generate the td's)
/Jeppe
Hi,
I'm exploring the new CSS selector binding functionality and must say
that it rocks!
One thing I can't seem to figure out:
I need to bind lists but also supply different attributes for each
item in the list.
E.g I want to end up with this:
<tr valign="top">
<td align="right" class="fieldname" style="width: 30%;" />
<td id="header" class="weekday" style="width: 10%">Ma 25-10</td>
<td class="weekday clearable" style="width: 10%">Ti 26-10</td>
<td class="weekday clearable" style="width: 10%">On 27-10</td>
<td class="weekday clearable" style="width: 10%">To 28-10</td>
<td class="weekday clearable" style="width: 10%">Fr 29-10</td>
<td class="weekend clearable" style="width: 10%">Lø 30-10</td>
<td class="weekend clearable" style="width: 10%">Sø 31-10</td>
</tr>
Note the different classes on the td elements. If I do
"#header *" #> plan.dates.map {_.toString}
they all get the weekday class.
Any way to solve this (besides moving the bind up to the tr and
generate the td's)
/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.
> On Tue, Nov 23, 2010 at 1:46 PM, Jeppe Nejsum Madsen <je...@ingolfs.dk>wrote:
>
>> Hi,
>>
>> I'm exploring the new CSS selector binding functionality and must say
>> that it rocks!
>>
>> One thing I can't seem to figure out:
>>
>> I need to bind lists but also supply different attributes for each
>> item in the list.
>>
>> E.g I want to end up with this:
>>
>> <tr valign="top">
>> <td align="right" class="fieldname" style="width: 30%;" />
>> <td id="header" class="weekday" style="width: 10%">Ma 25-10</td>
>> <td class="weekday clearable" style="width: 10%">Ti 26-10</td>
>> <td class="weekday clearable" style="width: 10%">On 27-10</td>
>> <td class="weekday clearable" style="width: 10%">To 28-10</td>
>> <td class="weekday clearable" style="width: 10%">Fr 29-10</td>
>> <td class="weekend clearable" style="width: 10%">Lø 30-10</td>
>> <td class="weekend clearable" style="width: 10%">Sø 31-10</td>
>> </tr>
>>
>> Note the different classes on the td elements. If I do
>>
>> "#header *" #> plan.dates.map {_.toString}
>>
>
> "#header" #> plan.dates.map{ d => "* *" #> d.toString & "* [class]" #> (if
> (d.isWeekday) "weekday" else "weekend")}
Nice, that works (after changing from M1 to SNAPSHOT).
I'm still trying to wrap my head around these bindings. My only info for
the CSS binding style is from
http://www.assembla.com/wiki/show/liftweb/Binding_via_CSS_Selectors (I
haven't read the source yet :-) and I can't quite seem to connect the above
code with the info on the wiki page.
My interpretation:
1) "#header" is bound to a List[NodeSeq=>NodeSeq]. Is there an implicit
that converts to IterableFunc?
2) Each of the NodeSeq=>NodeSeq gets called with the #header element as input
3) The "* *" (the first "*" which I can't see from the Wiki) means "replace child
content on all elements"?
4) The "* *" & "* [class]" functions are combined to a single
NodeSeq=>NodeSeq. Which one is applied first? Is it left to right? Or
functional composition?
This seems immensely powerful but also need some time (for me at least
:-) to sink in....
/Jeppe
2) Each of the NodeSeq=>NodeSeq gets called with the #header element as input
3) The "* *" (the first "*" which I can't see from the Wiki) means "replace child
content on all elements"?
4) The "* *" & "* [class]" functions are combined to a single
NodeSeq=>NodeSeq. Which one is applied first?
Is it left to right? Or
functional composition?
This seems immensely powerful but also need some time (for me at least
:-) to sink in....
/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.