framework
framework copied to clipboard
addPostPageJavaScript added twice to a page
As discussed with David
Sample app here: https://github.com/fmpwizard/lift_starter_2.4/tree/comet-fixedRender-issue
git clone [email protected]:fmpwizard/lift_starter_2.4.git
cd lift_starter_2.4
git checkout comet-fixedRender-issue
sbt
(note the branch name comet-fixedRender-issue )
Calling addPostPageJavaScript from fixedRender like this:
override def fixedRender: Box[NodeSeq] = {
S.session map { sess =>
sess.addPostPageJavaScript( () => JsCmds.Alert("hi") )
}
logger.info("called fixed render")
NodeSeq.Empty
}
results in the html having the alert("hi") twice.
What happens if you use S.appendJs? Does that differ from what addPostPageJavaScript should do?
I'll try that and post back
So I'm actually slightly confused right now… The bug demonstrated in the linked repository branch seems to be that when you load the page, the alert runs twice. However, at least with 2.6-RC1, opening a new tab only causes two alerts on the second page—the original page is untouched. The README in the target repository seems to indicate I should be seeing things run in the original page as well?
Okay, did a bit of investigating here. This is a bit tangled up because S.jsToAppend looks up the post page functions, but so does CometActor's fixedRender. Both are used by the CometActor to append JS—one OnLoad, in the ActionMessageSet handler, and one directly, in the base fixedRender implementation.
I have very little idea about how these two pieces and fixedRender are supposed to interact, so I'm going to leave this for another rainy day.
Oh… I think this is actually entirely fixed as of #1711, and therefore as of Lift 3.0.0. Will need to double-check.