framework icon indicating copy to clipboard operation
framework copied to clipboard

addPostPageJavaScript added twice to a page

Open fmpwizard opened this issue 12 years ago • 5 comments

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.

fmpwizard avatar Mar 20 '13 20:03 fmpwizard

What happens if you use S.appendJs? Does that differ from what addPostPageJavaScript should do?

Shadowfiend avatar May 13 '14 22:05 Shadowfiend

I'll try that and post back

fmpwizard avatar May 13 '14 23:05 fmpwizard

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?

Shadowfiend avatar Aug 09 '14 21:08 Shadowfiend

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.

Shadowfiend avatar Aug 09 '14 21:08 Shadowfiend

Oh… I think this is actually entirely fixed as of #1711, and therefore as of Lift 3.0.0. Will need to double-check.

Shadowfiend avatar Jul 18 '17 15:07 Shadowfiend