Only the first declared class is picked up.
val xml = <a class="link field" href="#">link text</a>
val func =
".field [id]" #> "fieldId" &
".link [href]" #> "
http://example.org"
println(func.apply(xml)) ml))
results in
<a href="
http://example.org" class="link field">link text</a>
reverse the class declarations and you get
<a id="fieldId" href="#" class="field link">link text</a>
I had a look through the code around the fix dpp did for the multiple
ids in css selector (
http://groups.google.com/group/liftweb/
browse_thread/thread/c50d6ee416f77692/0f2b532956a592a8?lnk=gst&q=css
+selector+class#0f2b532956a592a8)
and the problem I think is with
def findClass(clz: List[String]): Box[List[CssBind]] = clz match {
case Nil => Empty
case x :: xs =>
clzMap.get(x) match {
case Some(cb) => Full(cb)
case _ => findClass(xs)
}
}
line 1782 in framework/lift-base/lift-util/src/main/scala/net/liftweb/
util/BindHelpers.scala
If I'm reading this right, it'll only find the first match.
My use case is that I have a table full of events, which can be
suspended (so would be greyed out to customers) or unpublished (so
would be hidden from customers). Someone in an admin interface could
change these statuses and the front end automatically hides/greys out
the corresponding rows. The designer would flag the elements that he
wanted to change on these actions with the suspendable or publishable
class (perhaps he wants the whole row to grey out, perhaps just the
description for example), and in the back end I would use that info in
my bindings to attach element ids/classes for the suspended/
unpublished opps. As an admin changed the status, my Comet Actor sends
out further javascript to hide/change the classes on the opps.
Hmm - verbal may not be clear:
HTML:
<div class="event"> <tr class="suspendable publishable" >
<td > <span class="event_desc_w">Default event
description </span> </td>
</tr></div>
should become
<div class="event"> <tr class="suspendable publishable
suspended" id="event_1" style="display: none;">
<td > <span class="event_desc_w"
id="event_desc_1">unpublished, suspended event </span> </td>
</tr></div>
using selectors:
& ".unpublishable [id]" #> ("event_id_" +
event.id.is.toString)
& ".unpublishable [style]" #> {
if (
event.published.is == false) {
"display: none;"
} else {
"display: block"
}
}
& ".suspendable [id]" #> ("event_id_" +
event.id.is.toString) // id needs to be set - may not be both
publishable and suspendable
& ".suspendable [suspended]" #> {if (
event.suspended.is ==
false) {"suspended"} else {"unsuspended"}}
<js update code upon message omitted>
Each class works individually, but obviously doesn't work if I put
them both in.
I think this is probably a bug, as multiple classes is a pretty common
thing, and there are classes to support adding multiple classes in
lift.
I can file the bug, and write the test, and have a think about how
this could be fixed - but my scala fu is still pretty weak.
Catherine