Commit 6d866b44 authored by Nigel McNie's avatar Nigel McNie
Browse files

Broke rewriting one pagination link out into a separate method, so it can be...

Broke rewriting one pagination link out into a separate method, so it can be used outside this class.
parent 4ae1bfe5
......@@ -26,34 +26,38 @@ var Paginator = function(id, datatable, script, extradata) {
// If there is a link
if (a) {
connect(a, 'onclick', function(e) {
e.stop();
var loc = a.href.indexOf('?');
var queryData = [];
if (loc != -1) {
queryData = parseQueryString(a.href.substring(loc + 1, a.href.length));
queryData.extradata = serializeJSON(self.extraData);
}
sendjsonrequest(self.jsonScript, queryData, 'GET', function(data) {
getFirstElementByTagAndClassName('tbody', null, self.datatable).innerHTML = data['data']['tablerows'];
// Update the pagination
var tmp = DIV();
tmp.innerHTML = data['data']['pagination'];
swapDOM(self.id, tmp.firstChild);
// Run the pagination js to make it live
eval(data['data']['pagination_js']);
// Update the result count
getFirstElementByTagAndClassName('div', 'results', self.id).innerHTML = data['data']['count'] + ' results'; // TODO i18n
});
});
self.rewritePaginatorLink(a);
}
});
}
this.rewritePaginatorLink = function(a) {
connect(a, 'onclick', function(e) {
e.stop();
var loc = a.href.indexOf('?');
var queryData = [];
if (loc != -1) {
queryData = parseQueryString(a.href.substring(loc + 1, a.href.length));
queryData.extradata = serializeJSON(self.extraData);
}
sendjsonrequest(self.jsonScript, queryData, 'GET', function(data) {
getFirstElementByTagAndClassName('tbody', null, self.datatable).innerHTML = data['data']['tablerows'];
// Update the pagination
var tmp = DIV();
tmp.innerHTML = data['data']['pagination'];
swapDOM(self.id, tmp.firstChild);
// Run the pagination js to make it live
eval(data['data']['pagination_js']);
// Update the result count
getFirstElementByTagAndClassName('div', 'results', self.id).innerHTML = data['data']['count'] + ' results'; // TODO i18n
});
});
}
this.init(id, datatable, script, extradata);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment