n
n
nexo
Search…
Event system

n.on(event, function);

Comunicate any component in anyone direction
1
n.ready(() => {
2
3
n.render('eventTest', 'main')
4
5
n.on('sayHi', name => {
6
console.log(`Hi ${name}!`)
7
})
8
9
})
Copied!

Emit with component click:

1
n.set({
2
name: 'eventTest',
3
html: n => `
4
NAME: <input type="text" id="name">
5
<div id="sendEvent">CLICK FOR SEND NAME IN EVENT</div>
6
`,
7
ready: n => {
8
n.on('#sendEvent', 'click', () => {
9
n.emit('sayHi', n.id('name').value)
10
})
11
}
12
})
Copied!
Last modified 1yr ago