Skip to content

Instantly share code, notes, and snippets.

@sagar-ganatra
Created December 13, 2016 09:27
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 sagar-ganatra/c04531ce026a08b6dcb57fa6dfa8059b to your computer and use it in GitHub Desktop.
Save sagar-ganatra/c04531ce026a08b6dcb57fa6dfa8059b to your computer and use it in GitHub Desktop.
A FlightJS component that adds a click event handler and attaches it to an existing DOM node
// create a flight component
var AboutMeBtn = flight.component(aboutMe);
// component definition
function aboutMe () {
// event listener for the click event
this.onAboutMeBtnClick = function () {
alert('About me');
};
// after the component has been initialized, attched the event listener
this.after('initialize', function () {
this.on('click', this.onAboutMeBtnClick);
});
}
// attach the component to the DOM node with id - aboutMeBtn
AboutMeBtn.attachTo('#aboutMeBtn');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment