Have ideas to improve npm?Join in the discussion! »

@frzr/view

0.0.4 • Public • Published

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.
  • 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 for view.addListener(view.$find('#id'), 'click', onClick)

events

  • add: triggered when View is added
  • remove: triggered when View is removed

Keywords

none

Install

npm i @frzr/view

DownloadsWeekly Downloads

5

Version

0.0.4

License

MIT

Last publish

Collaborators

  • avatar