Skip to content

Instantly share code, notes, and snippets.

@techwraith
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techwraith/9239480 to your computer and use it in GitHub Desktop.
Save techwraith/9239480 to your computer and use it in GitHub Desktop.
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()
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()
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