Hi all.
I found a bug which I think is a blocker for 3.0-final.
After switching to 3.0-RC3 (where the on*-event stuff is fixed for AJAX-response) we started experiencing JS-events not working. It appears it is because the returned markup from AppendHtml, where the markup contains on*-events is something like this:
jQuery('#' + "F397700660391T24JCX").append(((function () {
lift.onEvent("lift-event-js-F397700660826TXLHFS", "click", function (event) {
EmailSend.downloadFileFix(event);
});
lift.onEvent("lift-event-js-F397700660827VELI0U", "click", function (event) {
lift.ajax("F397700660825QGZIET=true", null, null, null);
return false;
});
return "<div id=\"F3977006608239FSFEM\" class=\"attachment\">\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0009<span><span class=\"fileIcon jpg\"></span></span>\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0009<span class=\"fileName\"><a id=\"lift-event-js-F397700660826TXLHFS\" data-lift-removed-attributes=\"onclick\" href=\"/visena/origo/no/email/attachment/1669/62/fisk2(1).JPG?F397700660824RLLG1S=_\">fisk2(1).JPG</a></span>\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0009<span class=\"type\">image/jpeg</span>\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0009<span class=\"size\">5.41 M</span>\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0009<a id=\"lift-event-js-F397700660827VELI0U\" data-lift-removed-attributes=\"onclick\" class=\"iconDelete\"><img src=\"/visena/files/web/images/icons/16/delete.png\"></a>\u000a\u0009\u0009\u0009\u0009\u0009\u0009</div>";
})()));
Here you see that the events are installed by lift.onEvent() before the markup is appended to the DOM.
This is because the AppendHtml is defined like this:
case class JqAppend(content: NodeSeq) extends JsExp with JsMember {
override val toJsCmd =
"append("+fixHtmlFunc("inline", content){a => a}+")"
}
object AppendHtml {
def apply(uid: String, content: NodeSeq): JsCmd =
JqJE.JqId(JE.Str(uid)) ~> JqJE.JqAppend(content)
}
If, however, I use a custom version OrigoAppendHtml, like the one below, it works:
private case class Append(content: NodeSeq) extends JsExp with JsMember {
override val toJsCmd = fixHtmlCmdFunc("inline", content){"append(" + _ + ")"}
}
object OrigoAppendHtml {
def apply(uid: String, content: NodeSeq): JsCmd =
JqId(JE.Str(uid)) ~> Append(content)
def apply(exp: JsExp, content: NodeSeq): JsCmd =
(Jq(exp) ~> Append(content)).cmd
}
Is there a reason why we use fixHtmlFunc, and not fixHtmlCmdFunc? And shouldn't the call to "append" , in JqAppend.toJsCmd be "inside" fixHtmlFunc, like in my custom Append-class
I see the same applies to PrependHtml and maybe others.
I propose to fix this before 3.0-final, or else it is actually broken...
--
Andreas Joseph Krogh
CTO / Partner - Visena AS
Mobile: +47 909 56 963