Last active
August 29, 2015 13:56
-
-
Save techwraith/9239480 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Base = require('ribcage-view') | |
var SubView = Base.extend({ | |
action: function () { | |
this.options.action() | |
} | |
}) | |
var View = Base.extend({ | |
foo: 'bar' | |
, afterRender: function () { | |
var self = this | |
this.subview = new SubView({ | |
action: function () { | |
console.log(self.foo) | |
} | |
}) | |
} | |
}) | |
var myview = new View({}) | |
myview.render() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bind = require('lodash.bind') | |
var Base = require('ribcage-view') | |
var SubView = Base.extend({ | |
action: function () { | |
this.options.action() | |
} | |
}) | |
var View = Base.extend({ | |
foo: 'bar' | |
, logFoo: function () { | |
console.log(this.foo) | |
} | |
, afterRender: function () { | |
this.subview = new SubView({ | |
action: bind(this.logFoo, this) | |
}) | |
} | |
}) | |
var myview = new View({}) | |
myview.render() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Base = require('ribcage-view') | |
var SubView = Base.extend({ | |
action: function () { | |
this.options.action() | |
} | |
}) | |
var View = Base.extend({ | |
foo: 'bar' | |
, logFoo: function () { | |
console.log(this.foo) | |
} | |
, afterRender: function () { | |
this.subview = new SubView({ | |
action: this.logFoo | |
}) | |
} | |
}) | |
window.foo = 'baz' | |
var myview = new View({}) | |
myview.render() //!!! this will log `baz` when myview.subview.action is called |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment