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

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -