Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 7th, 2012  |  syntax: None  |  size: 1.51 KB  |  views: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. headerView = Backbone.View.extend({
  2.  
  3.         el: $('#' + targetdiv),
  4.         collection: orderedPrefs,
  5.         events: {
  6.             "click .scheduleheader": "clicked"                               // dependency here on scheduler.js class naming .scheduleheader
  7.  
  8.         },
  9.         initialize: function () {
  10.             _.bindAll(this, "render");
  11.  
  12.         },
  13.         render: function () {
  14.             alert('render!!');
  15.         },
  16.        
  17. this.collection.on("add", this.render);
  18. this.collection.on("remove", this.render);
  19. this.collection.on("reset", this.render);
  20.        
  21. new headerView({ collection: orderedPrefs });
  22.        
  23. var ModelView = Backbone.View.extend({
  24.     initialize: function() {
  25.         _.bindAll(this, "render");
  26.         this.render();
  27.         this.model.on("change",this.render);
  28.     },
  29.     render: function() {
  30.         $(this.el).html("model view markup"); // you should use templating
  31.         return this;
  32.     }
  33. });
  34.  
  35. var headerView = Backbone.View.extend({
  36.     el: $('#' + targetdiv),
  37.     initialize: function () {
  38.         _.bindAll(this, "render");
  39.         this.collection.on("add", this.render);
  40.         this.collection.on("remove", this.render);
  41.         this.collection.on("reset", this.render);
  42.     },
  43.     render: function () {
  44.         var self = this;
  45.         this.collection.each(function(collectionModel){
  46.             var view = new ModelView({ model : collectionModel });
  47.             $(self.el).append(view.el);
  48.         });
  49.     }
  50. });
  51.        
  52. this.collection.on("add", this.render);
  53.        
  54. this.collection.on("add remove", this.render);
clone this paste RAW Paste Data