Detailed description of ajax + jtemplate for dynamic paging, ajaxjtemplate

Source: Internet
Author: User

Detailed description of ajax + jtemplate for dynamic paging, ajaxjtemplate

Jtemplate is a JQuery-based template engine plug-in with powerful functions. With jtemplate, you no longer have to worry about using JS to bind datasets.

The main idea is to copy textarea as a template. ajax loads json data, adds a template, binds data, and updates and loads more events.

// Load more function fnload(data‑upload listdata.ajax.data.tar get_page = parseInt (data. currentPage) + 1; function addmore () {listData. ajax. load ();} // dynamically loads more tags if (data. totalNums = 0){{({loadobj}}.addclass({font-disable}}.html ("no data has been entered! "). Else ("it's already at the bottom !"). Unbind ("click") ;}// Ajaxcallbackfunction callBackList (data) {var nextHtml =$ ('# listtemplate '). prop ("outerHTML"); var $ listObj = listPage = 0? '# ListObj': '# listObj' + listPage; var $ nextListObj = 'listobj '+ (listPage + 1); $ ($ listObj ). setTemplateElement ('listtemplate', null, {filter_data: false}); $ ($ listObj ). setParam ("imgDomain", roomImgDomain); $ ($ listObj ). processTemplate (data); $ ($ listObj ). after ($ ('<div> </div>', {id: $ nextListObj, class: 'LIST-wrap '})); $ ('#' + $ nextListObj ). append (nextHtml); listPage ++; var $ firstH3 =$ ("# listObj. view-box: first h3 "); $ FirstH3.next (). show (); $ firstH3.find ("span "). addClass ("h3-up "). removeClass ("h3-down"); fnLoad (data) ;}} // ajax $ Ajax. prototype. load = function () {var _ this = this; $. ajax ({type: "post", url: _ this. url, dataType: 'json', data: _ this. data, success: function (data) {if (_ this. callBack) {_ this. callBack (data, _ this. id);} else {// console. log ("ajax undefined callback function! ");}}, Error: function () {// console. log ("ajaxerror") ;}}) ;}// call function fnListAjax () {this. ajax = new $ Ajax (); this. ajax. url = ""; this. ajax. data ={};} var listData = new fnListAjax (); fnAjax (); function fnAjax () {listData. ajax. url = dataDomain + "/advert/detail.htm"; listData. ajax. data = {code: 'index _ web'}; listData. ajax. callBack = fnCallBackView; listData. ajax. load ();};

The above content shares with you the ajax + jtemplate Implementation of Dynamic paging, I hope you like it.

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.