Skip to content

Instantly share code, notes, and snippets.

@sumitngupta
Created August 22, 2011 22:12
Show Gist options
  • Select an option

  • Save sumitngupta/1163766 to your computer and use it in GitHub Desktop.

Select an option

Save sumitngupta/1163766 to your computer and use it in GitHub Desktop.
/*jslint white: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true, indent: 2, browser: true, sloppy: true */
/*global $, JST, Backbone, Pipeline, window */
Pipeline.Views.PaginatedView = Backbone.View.extend({
tagName: 'tr',
className: 'pagination',
initialize: function () {
_.bindAll(this, 'previous', 'next', 'render');
this.collection.bind('refresh', this.render);
this.initializeTemplate();
},
events: {
'click a.prev': 'previous',
'click a.next': 'next',
'click a.page': 'goToPage'
},
initializeTemplate: function () {
this.template = _.template(JST['shared/pagination'](this.collection.pageInfo()));
},
render: function () {
$(this.el).html(this.template());
return this;
},
previous: function () {
this.collection.previousPage();
return false;
},
next: function () {
this.collection.nextPage();
return false;
},
goToPage: function () {
console.log('this is this: ');
console.log(this);
this.collection.goToPage();
return false;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment