dev chez Canal+
class View extends Bacbone.View { constructor(props){ super(props) } }
Backbone.View est une function
View.prototype --> Backbone.View.prototype --> Object.prototype
new View();
var View = Backbone.View.extend({ model: new WelcomeModel(), template: _.template(...), events: { 'click #button': 'hideRedText', }, initialize: function(){}, .... });
extend: function(protoProps){ var parent = Backbone.view; var child = function(){ return parent.apply(this, arguments); }; var Surrogate = function(){ this.constructor = child; }; Surrogate.prototype = parent.prototype; child.prototype = new Surrogate; _.extend(child.prototype, protoPros); // OH !! return child; }
new View(); // creation de cid delegateEvents: function(events) { var events = _.result(this, 'events')); //OH NO !! ... }
By Florent DUVEAU