Class puredom.ViewManager
- Defined in: ViewManager.js
- Extends puredom.EventEmitter
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
puredom.ViewManager(options)
Manages views, providing methods for loading, templating, caching and swapping.
|
| Field Attributes | Field Name and Description |
|---|---|
|
ID prefix for view storage.
|
Method Summary
| Method Attributes | Method Name and Description |
|---|---|
|
addView
(name, view)
Register a named view.
|
|
|
addViewPostProcessor
(callback)
Register a post-processor function that will be run on all loaded views.
|
|
|
destroy
()
Teardown and cleanup the manager.
|
|
|
exists
(name)
Check if a named view is registered.
|
|
|
init
(options)
Initialize the manager.
|
|
|
load
(name, insertInto, insertBefore, cloneOriginal, caching)
Load a view.
|
|
|
template
(name, fields, insertInto, insertBefore)
Load a view and immediately template it.
|
|
|
unload
(ui, unCache)
Destroy a view.
|
- Methods borrowed from class puredom.EventEmitter:
- emit
- on
- once
- removeListener
Class Detail
puredom.ViewManager(options)
Manages views, providing methods for loading, templating, caching and swapping.
- Parameters:
- {Object} options Optional
- Hashmap of options to be given to the instance.
- {Object} options.init Optional, Default: false
- Immediately calls init(options) for you
- {Object} options.viewDomPrefix Optional, Default: views_
- Custom DOM cache ID prefix
- {Object} options.cacheBase Optional, Default: document.body
- Move the DOM view cache
Field Detail
viewDomPrefix
ID prefix for view storage.
Method Detail
-
addView(name, view)Register a named view.
- Parameters:
- {Any}name
- {Any}view
-
addViewPostProcessor(callback)Register a post-processor function that will be run on all loaded views.
The function gets passed the view base as a puredom.NodeSelection.- Parameters:
- {Any}callback
-
destroy()Teardown and cleanup the manager.
-
exists(name)Check if a named view is registered.
- Parameters:
- {Any}name
-
init(options)Initialize the manager.
- Parameters:
- {Object} options Optional
- Hashmap of options.
- {Object} options.viewDomPrefix Optional, Default: views_
- Custom DOM cache ID prefix
- {Object} options.cacheBase Optional, Default: document.body
- Move the DOM view cache
-
{puredom.NodeSelection} load(name, insertInto, insertBefore, cloneOriginal, caching)Load a view.
- Parameters:
- {String} name
- The named view to load
- {HTMLElement} insertInto Optional
- Immediately insert the view into an parent
- {HTMLElement} insertBefore Optional
- Inject view into the parent of this node, before this node.
- {Boolean} cloneOriginal Optional, Default: true
- Set this to false to hijack previously rendered DOM views.
- {Boolean} caching Optional, Default: true
- Set this to false to turn off view caching.
- Returns:
- {puredom.NodeSelection} view, or false on error.
-
template(name, fields, insertInto, insertBefore)Load a view and immediately template it.
See puredom.ViewManager#load- Parameters:
- {Any}name
- {Any}fields
- {Any}insertInto
- {Any}insertBefore
-
unload(ui, unCache)Destroy a view.
- Parameters:
- {Any}ui
- {Any}unCache