jquery - Correct way to use Mustache.js? -
i using mustache.js templating engine.
on page load, create list of items send ajax request:
private static list<items> items; protected void page_load(object sender, eventargs e) { items = service.getmyitems(0, "text", "sometext"); }
in view, ask items using ajax call:
<script> getmyitemsbyajax(); </script>
which, on success, creates mustache html items, , appends control.
i way, avoid waiting time blank page while items list being created.
i curious: there smarter way of doing this?
your way valid. thing question necessity of using mustache. unless you're generating complex html mustache template alleviate, can append items in ajax callback function , skip client side templating.
it's balance between:
- loading mustache library + creating mustache template or
- generate html in ajax callback.
Comments
Post a Comment