Skip to content

Plugin: Event plugin

podefr edited this page · 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)
    completed: false
<!--  And in the dom -->    
<input type="text" placeholder="What needs to be done?" data-event="listen:keydown,addTask;" /> 
Something went wrong with that request. Please try again.