Component
The main class that will be extended when a new componenet is created. Extend this class with es6 syntax.
Example:
import { Component } from "./core/bane"
class ArticlesComponent extends Component {
initialize() {
this.events = {
"click .foo": "fooClicked"
}
}
render() {
//...
}
fooClicked() {
//...
}
}
Test:
Constructor Summary
Public Constructor | ||
public |
constructor(options: [Options]) Constructs a component |
Method Summary
Public Methods | ||
public |
This method actually builds the template and inserts the HTML into the DOM |
|
public |
Pull data off of a custom data attribute |
|
public |
|
|
public |
Publish an event on the |
|
public |
Override this method with custom rendering logic |
Public Constructors
Public Methods
public build(data: Object): jQuery source
This method actually builds the template and inserts the HTML into the DOM
Params:
Name | Type | Attribute | Description |
data | Object | The data to pass to a template function |
Return:
jQuery | Returns the element |
public getInitialState(): Object source
Pull data off of a custom data attribute data-lp-initial-abc
.
This allows for server side JSON data to be embeded in the document.
Example:
HTML
<div data-lp-initial-cards="{{cards}}"></div>
JavaScript
let state = this.getInitialState();
state.cards; // { cards: ... }