General API
build()
Runs components with data based on a DOM element and a specified event, with support for setting custom events.
-
Accepts an object as its first argument, which must include an "it" property containing a DOM element with a "data-*" attribute for the desired event.
Accepts a string as the second argument, which contains the event name. - Returns true on success; otherwise, returns false.
- It is not necessary to wait for the method to be executed using await if not needed.
Example:
// <div data-click="component_1" data-myEvent="component_2: {'book': [1, 2]}"></div>
build({it: $('div')}, 'click');
build({it: $('div')}, 'myEvent');
evt.add('click', (e) => {
e.it = e.target;
build(e, 'click');
});
// Waits for the method to complete its execution.
await build({it: $('div')}, 'click');
evt.add('click', async (e) => {
e.it = e.target;
await build(e, 'click');
});