Skip to content

Instantly share code, notes, and snippets.

@marcobarbosa
Last active December 17, 2015 18:59
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 marcobarbosa/5656808 to your computer and use it in GitHub Desktop.
Save marcobarbosa/5656808 to your computer and use it in GitHub Desktop.
Flight delegation
define(
[
'flight/component'
],
function (defineComponent) {
return defineComponent(helloWorld);
function helloWorld() {
this.injectFooBar = function() {
// Silly example but here I inject
// an element that interests foobar.
// But since it's done after initialization
// foobar won't catch it.
var $newElement = "<div class=\"foobar\"></div>";
this.$node.append( $newElement );
// Could I maybe:
// fooBarUI.attachTo($newElement) - or something?
}
}
}
);
define(
[
'flight/component'
],
function (defineComponent) {
return defineComponent(fooBar);
function fooBar() {
this.doStuff = function() {
// ...
}
this.after('initilize'injectFooBar = function() {
// add listeners on nodes inside .foobar
}
}
}
);
define(
[
'ui/foobar',
'ui/helloworld'
],
function(
fooBarUI,
helloWorldUI) {
var initialize = function() {
foobar.attachTo('.foobar');
helloWorld.attachTo('#hello-world');
}
return {
initialize: initialize
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment