Lift 3.0 RC3: inline JS replacement in requests without head and body

26 views
Skip to first unread message

Peter Brachwitz

unread,
Sep 8, 2016, 8:05:58 AM9/8/16
to Lift
I have a problem in a legacy application with the new inline JS replacement in (Ajax) requests that use snippets to render HTML but don't return a full HTML page. 

When the HTML content returned does not contain a head and body tag it seems to me that the inline JS is replaced but the event handling code is not delivered to the client. 

The onclick events are thereby essentially removed from the nodes. 


from LiftMerge:
if (!hasHtmlHeadAndBody) {
val fixedHtml =
normalizeMergeAndExtractEvents(xhtml, HtmlState(mergeHeadAndTail = false)).nodes //what happens to the js?

fixedHtml.find {
case e: Elem => true
case _ => false
} getOrElse Text("")
} else {

....

Maybe I am missing something essential here. But any pointers to a solution are much appreciated!

Antonio Salazar Cardozo

unread,
Sep 8, 2016, 8:24:28 AM9/8/16
to Lift
I'm going to be implementing a way to disable event extraction sometime soon
as it's revealed unexpectedly strange uses of certain aspects of inline JS in a
variety of cases (not surprising, of course) that aren't necessarily solvable. So,
that should help you in this case as well, at least as we work out the kinks. It should
really have been implemented with such a toggle from the beginning, and I'm rather
embarrassed that I didn't do so.

Since you're doing this request via AJAX but seemingly not through Lift's
AJAX plumbing, I see that edge case isn't really handled above. The reason is
because LiftMerge can be run in a standard AJAX request as well, at which point
the JS in question will be appended via `S.appendJs`. Though now that I look more
closely, perhaps that wouldn't happen if run through LiftMerge even in that case…

Anyway, I'll have a closer look. Can you file an issue please?
Thanks,
Antonio

Peter Brachwitz

unread,
Sep 8, 2016, 8:51:25 AM9/8/16
to Lift

Antonio Salazar Cardozo

unread,
Sep 8, 2016, 11:57:40 AM9/8/16
to Lift

❤️

Reply all
Reply to author
Forward
0 new messages