Use templates to generate the HTML framework jquery. tmpl detailed instructions _ jquery

Source: Internet
Author: User
This article mainly introduces jquery, a framework for generating HTML with templates. tmpl Usage Details. If you need a friend, you can refer to the dynamic request data to update the page. This is a very common method, such as dynamic loading of blog comments by pages, weibo rolling loading and timed request loading.

In these cases, the data returned by the dynamic request is generally not formatted as JSON or XML. In short, data is spelled out on the server rather than on the browser. However, from the perspective of the transmission volume, it is not cost-effective to return HTML. In terms of web transmission, JSON rather than XML is used.

The browser generates HTML based on JSON. It is annoying that when the structure is not complex, the structure is complicated and the browser wants to die, you need to carefully write JavaScript code that is barely maintained.

Therefore, jquery. tmpl is one of the frameworks that generate HTML using templates. The following describes the usage of jquery. tmpl in detail.

The following describes how to use it.:

First, we will introduce the template and data. Needless to say, these two must be indispensable.

The template can be defined in two ways. The specific code is given below

The Code is as follows:


Var markup ="

  • Some content: $ {item }.
    "
    + "More content :$ {myValue }.
  • ";

    $. Template ("movieTemplate", markup );



    The Code is as follows:


    Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.