-
Notifications
You must be signed in to change notification settings - Fork 1
Plugin: Event plugin
podefr edited this page Apr 4, 2012
·
1 revision
The event plugin adds listeners to a dom node to call a function in the OObject.
###Triggering controllers' methods on user inputs
// The event plugin takes the OObject as parameter.
// You can pass any other object too.
var eventPlugin = new EventPlugin(UI);
// We use the name "event" to call it from the dom
UI.plugins.add("event", eventPlugin);
// When called by the EventPlugin, addTask will receive the event and the corresponding dom node
UI.addTask = function (event, node) {
// The this object is the one passed to new EventPlugin (UI)
this.model.push({
name: node.name,
completed: false
})
}
<!-- And in the dom -->
<input type="text" placeholder="What needs to be done?" data-event="listen:keydown,addTask;" />