harryh
unread,Aug 26, 2009, 5:44:50 PM8/26/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Lift
Let's say you have a bit of a page like so:
<lift:SomeSnippet.section>
<foo:name/>
<lift:SomeSnippet.section>
Now, let's assume that computing whatever is bound to <foo:name/>
takes a long time (maybe it takes a network call, or a long database
query, or whatever). You don't want to hold up your entire page view
on that so.....
<lift:Util.lazyLoad>
<lift:SomeSnippet.section>
<foo:name/>
<lift:SomeSnippet.section>
</lift:Util.lazyLoad>
Then in your Util snippet:
def lazyLoad(xhtml: NodeSeq) = {
val id = "lazy"+System.currentTimeMillis()
val (name, exp) = ajaxInvoke(() => { SetHtml(id, xhtml) })
<div id={id}>
<img src="/img/ajax_spinner.gif" height="32" width="32" alt="wait"/
>
{Script(OnLoad(exp.cmd))}
</div>
}
Feel free to critique if there is a better way of doing this. It's
working pretty good for me so far though.
-harryh