Skip to content

Instantly share code, notes, and snippets.

@kylebuch8
Last active March 20, 2019 17:14
Show Gist options
  • Save kylebuch8/95c5e8318a77d78a7789c688374eee14 to your computer and use it in GitHub Desktop.
Save kylebuch8/95c5e8318a77d78a7789c688374eee14 to your computer and use it in GitHub Desktop.
Simple PFElement Constructor
// the location of pfelement.js may be different if you're not building an element in the
// PatternFly elements repository
import PFElement from "../pfelement/pfelement.js";
class MySimplePfelement extends PFElement {
constructor() {
// make sure we call super() first with the class we're using
// as the first argument
super(MySimplePfelement);
// example state data
this.opened = false;
// example binding of this to a private method
this._clickHandler = this._clickHandler.bind(this);
// example event listener
this.addEventListener("click", this._clickHandler);
}
_clickHandler(event) {
// handle the click event
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment