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.