Created
February 10, 2012 12:42
-
-
Save ivasilov/1789417 to your computer and use it in GitHub Desktop.
Faulty view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
InvoiceListView = require('views/invoiceListView').InvoiceListView | |
InvoicesTemplate = require('views/templates/invoices') | |
class exports.InvoicesView extends Backbone.View | |
events: | |
'click #next' : 'nextPage' | |
'click #prev' : 'prevPage' | |
initialize: -> | |
app.collections.invoices.on("reset",@reset, @) | |
reset:-> | |
@render(1) | |
render:(page) -> | |
if(app.views.main.rendered==false) | |
app.views.main.render(->app.views.invoices.subrender(page)) | |
else | |
app.views.invoices.subrender(page) | |
@ | |
subrender:(page) -> | |
@setElement('#rightpanel') | |
@page = page | |
$(@el).html InvoicesTemplate() | |
@renderPagination() | |
$('#page'+page).addClass('active') | |
@ | |
renderPagination: -> | |
pages = Math.ceil(app.collections.invoices.length / 10) | |
page = 1 | |
$('#last').before('<li id="page'+ page + '"><a href="#invoices/'+ page + '">' + page + '</a></li>') while page++ < pages | |
@ | |
prevPage: -> | |
num = '#page' + @page-1 | |
$(num).click() | |
@ | |
nextPage: -> | |
$('#page' + @page+1).click() | |
@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment