vendor/assets/javascripts/emerson/view.js in emerson-0.0.9 vs vendor/assets/javascripts/emerson/view.js in emerson-0.0.10

- old
+ new

@@ -124,31 +124,34 @@ // attribute. This may be used for a given outlet whether or not it has // been "connected". Outlets are useful as a means of allowing for View // and Trait definitions with somewhat flexible DOM. Rather than using // specific selectors (or polluting the `class` attribute), the DOM for // a given instance indicates which nodes should match for the View. + // + // thanks to Nathan Sobo for the idea: https://github.com/nathansobo/space-pen _.extend(View.prototype, { connect : function(config) { var self = this; var outlets = this.find('[data-outlet]'); if(config === true) { _.each(outlets, function(subject) { var outlet = $(subject); + var key = outlet.data('outlet'); self[outlet.data('outlet')] = function() { - return outlet; + return self.outlet(key); }; }); } else if($.isArray(config)) { _.each(config, function(key) { var outlet = self.find('[data-outlet="' + key + '"]'); if(outlet.length) { self[key] = function() { - return outlet; + return self.outlet(key); }; } }); } @@ -283,14 +286,14 @@ // experimental... instance(def, self, mode); // setup = def.setup; // built = def(self, self.context); // built.connect(setup.connected); - // + // // _.each(setup.subscribe, function(handler, key) { // bind(built, key, handler); // }); - // + // // setup.initialize.call(built, mode); set.push(id); } });