When you return a NodeSeq like that it gets merged with the original. I think what you want is more like this (untested):
".comment [class]" #> "comment"+post.id
Note that changing the class attribute will always append the class (not replace existing classes).From the wiki:"[attr] (e.g.,“#id [href]” ) replaces the matching attribute’s value with the values (note in the case of theclass attribute, the values are appended to the element’sclass attributes)."
On Dec 2, 2010, at 4:28 PM, David Brooks wrote:On 2 Dec 2010, at 15:25, Derek Williams wrote:
When you return a NodeSeq like that it gets merged with the original. Ithink what you want is more like this (untested):".comment [class]" #> "comment"+post.id
There's also a neat appending feature:
".comment [class+]" #> post.id
Cheers,
D
--
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.
--
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 Thu, Dec 2, 2010 at 9:04 AM, Mads Hartmann Jensen <mad...@gmail.com>wrote:
>
>> Note that changing the class attribute will always append the class (not
>> replace existing classes).
>>
>> From the wiki:
>>
>> "[attr] (e.g.,“#id [href]” ) replaces the matching attribute’s value with
>> the values (note in the case of theclass attribute, the values are appended
>> to the element’sclass attributes)."
>>
>
> By default, Helpers.bind() did not merge attributes. I changed the strategy
> with CSS Selector Transforms. Is the change good or bad?
I realise this question probably wasn't aimed at me, but I greatly prefer the [...+] syntax to the previous version (which made a special case for class attributes).
That said, [...+] seems to have introduced another special case for class:
".todo [class+]" #> "extra"
adds an extra space between the existing and new classes:
<span class="todo" /> -> <span class="todo extra" />
whereas this one:
"#todo [id+]" #> "extra"
appends id strings without a space:
<span id="todo" /> -> <span id="todoextra" />
I think it's unnecessary to make the special case of class here: it's easy to append a string with an extra space manually - e.g. " extra" - but it's hard to append without the extra space, should you want to.
Would it be possible to change #> so that it accepts a (String) => String on the RHS? Alternatively, would you consider making a special case of attributes (as with AttrBindParam in the old binding system)? By providing another method (e.g. #~>) that accepts a (String) => String, these sorts of manipulations might be a bit more natural.
I'm really loving the power flexibility of #>, by the way... #> { NodeSeq => NodeSeq } is a godsend!
Cheers,
D
On 2 Dec 2010, at 17:33, David Pollak wrote:I realise this question probably wasn't aimed at me, but I greatly prefer the [...+] syntax to the previous version (which made a special case for class attributes).
> On Thu, Dec 2, 2010 at 9:04 AM, Mads Hartmann Jensen <mad...@gmail.com>wrote:
>
>> Note that changing the class attribute will always append the class (not
>> replace existing classes).
>>
>> From the wiki:
>>
>> "[attr] (e.g.,“#id [href]” ) replaces the matching attribute’s value with
>> the values (note in the case of theclass attribute, the values are appended
>> to the element’sclass attributes)."
>>
>
> By default, Helpers.bind() did not merge attributes. I changed the strategy
> with CSS Selector Transforms. Is the change good or bad?
That said, [...+] seems to have introduced another special case for class:
".todo [class+]" #> "extra"
adds an extra space between the existing and new classes:
<span class="todo" /> -> <span class="todo extra" />
whereas this one:
"#todo [id+]" #> "extra"
appends id strings without a space:
<span id="todo" /> -> <span id="todoextra" />
I think it's unnecessary to make the special case of class here: it's easy to append a string with an extra space manually - e.g. " extra" - but it's hard to append without the extra space, should you want to.
Would it be possible to change #> so that it accepts a (String) => String on the RHS? Alternatively, would you consider making a special case of attributes (as with AttrBindParam in the old binding system)? By providing another method (e.g. #~>) that accepts a (String) => String, these sorts of manipulations might be a bit more natural.
I'm really loving the power flexibility of #>, by the way... #> { NodeSeq => NodeSeq } is a godsend!
Cheers,
D
--
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 Thu, Dec 2, 2010 at 9:04 AM, Mads Hartmann Jensen <mad...@gmail.com> wrote:Note that changing the class attribute will always append the class (not replace existing classes).From the wiki:"[attr] (e.g.,“#id [href]” ) replaces the matching attribute’s value with the values (note in the case of theclass attribute, the values are appended to the element’sclass attributes)."
By default, Helpers.bind() did not merge attributes. I changed the strategy with CSS Selector Transforms. Is the change good or bad?