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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to