Strange CSS selector behavior

50 views
Skip to first unread message

Riccardo Sirigu

unread,
Sep 26, 2017, 4:45:23 AM9/26/17
to Lift
I just noticed a strange behavior using Lift css selectors.

If I have an HTML like the following

 <div id="accept-box" class="accept-box">
     <button id="accept" class="accept"><lift:loc locid="accept"></lift:loc></button>
  </div>

And the following Snippet

def render = {
 
...
  "#accept" #> SHtml.ajaxButton("Accept", () => Alert("Confirmed")) 
}

The selector doesn't work and I have to specify the entire path, for example 

"accept-box" #> ("#accept" #> SHtml.ajaxButton("Accept", () => Alert("Confirmed"))) 

But if I change the parent div to 
id="accept_box" 
with the underscore, everything works perfectly.

From what I have seen, Lift has trouble with ids with the same prefix, when hyphenated.


Should I open an issue?

Antonio Salazar Cardozo

unread,
Sep 26, 2017, 2:02:44 PM9/26/17
to Lift
Whoa… If you could post an example project, and naturally also if you'd like to open an issue…
This sounds pretty nutty. But at the same time, I don't know that I would have exercised this
particular situation, so it may indeed be lurking!
Thanks,
Antonio
Message has been deleted

Riccardo Sirigu

unread,
Sep 27, 2017, 10:43:45 AM9/27/17
to Lift
My bad, 
there is also the selector

  "#accept-box" #> PassThru &
  "#accept" #> SHtml.ajaxButton("Accept", () => Alert("Confirmed"))

And I think Lift skips the #accept because it's inside #accept-box.

Whereas the following code, with andThen, works


  "#accept-box" #> PassThru andThen
  "#accept" #> SHtml.ajaxButton("Accept", () => Alert("Confirmed"))

Antonio Salazar Cardozo

unread,
Sep 27, 2017, 11:37:35 AM9/27/17
to Lift
That'll do it! I do wish `PassThru` specifically could be exempted from this requirement… Worth
looking into.
Thanks,
Antonio
Reply all
Reply to author
Forward
0 new messages