hooking up last button
This commit is contained in:
parent
a2e734139c
commit
1f34f63f97
@ -88,13 +88,13 @@
|
||||
<div class="viewpanel-sorting">
|
||||
</div>
|
||||
<div class="viewpanel-paging">
|
||||
<a id="paging-first" href="javascript:{}" class="inaction">« first</a>
|
||||
<a id="paging-previous" href="javascript:{}" class="inaction">‹ previous</a>
|
||||
<a href="javascript:{}" class="first inaction">« first</a>
|
||||
<a href="javascript:{}" class="previous inaction">‹ previous</a>
|
||||
<span class="viewpanel-pagingcount">
|
||||
1 - 10
|
||||
</span>
|
||||
<a id="paging-next" href="javascript:{}" class="action">next ›</a>
|
||||
<a id="paging-last" href="javascript:{}" class="action">last »</a>
|
||||
<a href="javascript:{}" class="next action">next ›</a>
|
||||
<a href="javascript:{}" class="last action">last »</a>
|
||||
</div>
|
||||
</div>
|
||||
<div id="dataTableContainer" class="data-table-container">
|
||||
|
||||
@ -5,7 +5,9 @@ var removalist = function() {
|
||||
}
|
||||
|
||||
function renderRows(rows) {
|
||||
|
||||
var tableRows = [];
|
||||
|
||||
rows.map(function(row) {
|
||||
var cells = [];
|
||||
app.headers.map(function(header) {
|
||||
@ -18,19 +20,22 @@ var removalist = function() {
|
||||
})
|
||||
tableRows.push({cells: cells});
|
||||
})
|
||||
|
||||
util.render('dataTable', 'dataTableContainer', {
|
||||
rows: tableRows,
|
||||
headers: app.headers
|
||||
})
|
||||
|
||||
app.newest = rows[0].id;
|
||||
app.oldest = rows[rows.length - 1].id;
|
||||
|
||||
}
|
||||
|
||||
function getPageSize() {
|
||||
return parseInt($(".viewpanel-pagesize .selected").text());
|
||||
}
|
||||
|
||||
function fetchRows(id) {
|
||||
function fetchRows(id, skip) {
|
||||
|
||||
var query = {
|
||||
"limit" : getPageSize()
|
||||
@ -41,6 +46,8 @@ var removalist = function() {
|
||||
if (id !== app.newest) $.extend( query, {"skip": 1});
|
||||
}
|
||||
|
||||
if (skip) $.extend( query, {"skip": skip});
|
||||
|
||||
var req = {url: app.baseURL + 'api/rows?' + $.param(query)};
|
||||
|
||||
couch.request(req).then(function(response) {
|
||||
|
||||
@ -23,7 +23,7 @@ app.routes = {
|
||||
|
||||
},
|
||||
page: function(id) {
|
||||
removalist.getPageSize()
|
||||
removalist.getPageSize();
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,8 +35,11 @@ app.after = {
|
||||
removalist.fetchRows(app.newest);
|
||||
});
|
||||
$( '.viewpanel-paging a' ).click(function( e ) {
|
||||
// var action = $(e.target).attr('id').split('paging-')[1];
|
||||
removalist.fetchRows(app.oldest);
|
||||
var action = $(e.target);
|
||||
if (action.hasClass("last")) removalist.fetchRows(false, app.dbInfo.doc_count - removalist.getPageSize());
|
||||
if (action.hasClass("next")) removalist.fetchRows(app.oldest);
|
||||
if (action.hasClass("previous")) removalist.fetchRows(app.oldest);
|
||||
if (action.hasClass("first")) removalist.fetchRows();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user