@frzr/view
v0.0.4
Published
frzr View
Downloads
1
Readme
view
FRZR View
installation
// with frzr
npm install frzr
// standalone
npm install @frzr/view
require
// with frzr
var View = require('frzr').View
// standalone
var View = require('@frzr/view')
usage
var view = new View(options)
options
- init: triggers when View is created
- template: HTML string to build the template from. Gets parsed and memoized.
Any other parameter will be added as a local attribute
methods
- $find(query): finds DOM elements inside template
- You can use
$find('$id')
to find<div frzr="id"></div>
superfast.
- You can use
- mount(target): mount to DOM (rest is automatic)
- mountBefore(target, before): mount to DOM (with insertBefore)
- addListener(target, eventName, cb): shortcut to addEventListener but listeners get removed when view is destroyed
- You can also use
view.addListener('#id', 'click', onClick)
as a shortcut forview.addListener(view.$find('#id'), 'click', onClick)
- You can also use
events
- add: triggered when View is added
- remove: triggered when View is removed