JQuery Templates

I am using jquery templates to display JSON input. I would like to load the template into a cache file. How to do it?

UPDATE
http://encosia.com/2010/12/02/jquery-templates-composite-rendering-and-remote-loading/ is
very close to the solution I ended up with, instead I used an iframe;

+3
source share
5 answers

It seems that there are several methods for implementing each of them with its advantages / disadvantages.

1) script. . ,

2) javascript. , .

3) JSON. , ?

4) iframe iframe - , /, ,

, , iframe, , .

+2

ajax- , aspx

$.ajax({ 
   url: "myprog.aspx", 
   data: { whichTemplate: "template I'm Looking for" }, 
   success: function(result) { 
                 // result is the text string containing either a single template or a delimated list of templates 
                 $.template('templatename', result); 
            } , 
   dataType: "text"
}); 
+2

, :

<script id="entry_show_template" defer type="text/html">
  <div class="entry">
    Age: <span class="age"></span> <a class="name" href="#"></a>
  </div>
</script>

, src, :

$('#entry_show_template') 
+1

See my answer for jQuery templates - where to put them?

In addition to the article from Dave Ward that you talked about in your question, he refers to some additional tricks from Introduction to jQuery Templates, Stephen Walter . In particular, it describes how to extract a template once and cache its compiled version.

0
source

Source: https://habr.com/ru/post/1774786/


All Articles