Created
December 13, 2016 09:27
-
-
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
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
// 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