Enclose your snippet like this:
Enclose your snippet like this:
You can also add the template
attribute to the lazy-load
snippet to
specify what to render as a placeholder:
Note that this must be a single element that will be replaced when the lazy
content is loaded. By default, an AJAX spinner is displayed inside a div
.
If you invoke this from Scala rather than markup, you can optionally
provide a placeholderTemplate
that is a NodeSeq
that should be used
while the async rendering takes place.
If you need to provide a custom renderer
function, perhaps because you
need to do further wrapping beyond what buildDeferredFunction
gives you,
then you can invoke this render
method directly and pass it a function
that will take the id of the placeholder container and render whatever
needs to be rendered to a JsCmd
.
If you need to provide a custom renderer
function, perhaps because you
need to do further wrapping beyond what buildDeferredFunction
gives you,
then you can invoke this render
method directly and pass it a function
that will take the id of the placeholder container and render whatever
needs to be rendered to a JsCmd
. The snippet will:
NodeSeq
isn't specified, first see if
S.attr("template")
is set and use that template if avilable, and then
fall back on the default placeholder template.AsyncRenderComet
correctly.The renderer
function will be wrapped in current request state you must
do this manually using buildDeferredFunction
. This method is for advanced
use; most folks will probably want to interact with the snippet by just
wrapping their snippet invocation in a data-lift="lazy-load"
snippet.
Enclose your snippet tags on your template with LazyLoad and the snippet will execute on a different thread, which avoids blocking the page render.