A simple way to use jquery plug-in Tmpl

Source: Internet
Author: User
Tags json

JavaScript can also use templates to solve these problems, such as the Jquery.tmpl based on JQuery, which has now been accepted as an official template plugin. Detailed API in the JQuery Templates, built-in demo also heartily demonstrates the various usages.

1. Introducing Scripts

2. Writing templates

2.1 Suppose there is at this time a data sent from a JSON format in the background

The code is as follows:

[{"TId": 1, "Tname": "John", "Tage": "Tclass": 1, "Teachclass": {"cId": 1, "CName": "1 Classes"}},

The code is as follows:

{"TId": 2, "Tname": "Dick", "Tage": "Tclass": 1, "Teachclass": {"cId": 1, "CName": "1 Classes"}},

The code is as follows:

{"TId": 4, "Tname": "Zhao Liu", "Tage": "Tclass": 2, "Teachclass": {"CId": 2, "CName": "2 Class"}]

2.2 At this point you want to display the following content

Then set the template according to the content you want to display:

"Similar to Repeater control in ASPX"

"Note: Remember to set the ID"

3. Fill in the template

According to the above assumptions, the background returns a JSON-formatted string, then through the AJAX request, and fill in the template

4. See the effect page

The above mentioned is the entire content of this article, I hope you can enjoy.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.