PageRenderTime 42ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/examples/netflix-client-paging/views/AppView.js

https://github.com/dgs700/backbone.paginator
JavaScript | 38 lines | 27 code | 11 blank | 0 comment | 0 complexity | f2cdf14806bab15e4c0645197398bec3 MD5 | raw file
Possible License(s): MIT
  1. (function ( views ) {
  2. views.AppView = Backbone.View.extend({
  3. el : '#content',
  4. initialize : function () {
  5. var tags = this.collection;
  6. tags.on('add', this.addOne, this);
  7. tags.on('reset', this.addAll, this);
  8. tags.on('all', this.render, this);
  9. tags.fetch({
  10. success: function(){
  11. tags.pager();
  12. },
  13. silent:true
  14. });
  15. },
  16. addAll : function () {
  17. this.$el.empty();
  18. this.collection.each (this.addOne);
  19. },
  20. addOne : function ( item ) {
  21. var view = new views.ResultView({model:item});
  22. $('#content').append(view.render().el);
  23. },
  24. render: function(){
  25. }
  26. });
  27. })( app.views );