new View(optionsopt)
View
Creating a conbo.View creates its initial element outside of the DOM,
if an existing element is not provided...
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> |
Object containing optional initialisation options, including 'attributes', 'className', 'data', 'el', 'id', 'tagName', 'template', 'templateUrl' |
Fires:
- conbo.ConboEvent#event:ADD
- conbo.ConboEvent#event:DETACH
- conbo.ConboEvent#event:REMOVE
- conbo.ConboEvent#event:BIND
- conbo.ConboEvent#event:UNBIND
- conbo.ConboEvent#event:TEMPLATE_COMPLETE
- conbo.ConboEvent#event:TEMPLATE_ERROR
- conbo.ConboEvent#event:PREINITIALIZE
- conbo.ConboEvent#event:INITIALIZE
- conbo.ConboEvent#event:INIT_COMPLETE
- conbo.ConboEvent#event:CREATION_COMPLETE
Extends
Members
attributes :Object
Attributes to apply to the View's element
Type:
- Object
autoInitTemplate :boolean
Whether or not the template should automatically be loaded and applied, rather than waiting for the user to call initTemplate (default: true)
Type:
- boolean
body :HTMLElement
A View's body is the element to which content should be added:
the View's content, if it exists, or the View's main element, if it doesn't
Type:
- HTMLElement
className :string
CSS class name(s) to apply to the View's element
Type:
- string
content :HTMLElement
The element into which HTML content should be placed; this is either the
first DOM element with a `cb-content` or the root element of this view
Type:
- HTMLElement
currentState :string
The current view state.
When set, adds "cb-state-x" CSS class on the View's element, where "x" is the value of currentState.
Type:
- string
data :Object
Arbitrary data Object
Type:
- Object
- Overrides:
- Source:
el :HTMLElement
This View's element
Type:
- HTMLElement
- Overrides:
- Source:
hasContent :boolean
Does this View support HTML content?
Type:
- boolean
hasTemplate :boolean
Does this view have a template?
Type:
- boolean
id :string
ID to apply to the View's element
Type:
- string
initialized :boolean
Has this view completed its life cycle phases?
Type:
- boolean
parent :conbo.View
Returns a reference to the parent View of this View, based on this
View element's position in the DOM
Type:
parentApp :conbo.Application
Returns a reference to the parent Application of this View, based on
this View element's position in the DOM
Type:
style :any
Object containing CSS styles to apply to this View's element
Type:
- any
subcontext :conbo.Context
The context that will automatically be applied to children
when binding or appending Views inside of this View
Type:
supro
Similar to `super` in ActionScript or Java, this property enables
you to access properties and methods of the super class prototype,
which is the case of JavaScript is the next prototype up the chain
- Inherited From:
- Source:
tagName :string
The tag name to use for the View's element (if no element specified)
Type:
- string
- Overrides:
- Source:
template :string
Template to apply to the View's element
Type:
- string
- Overrides:
- Source:
templateCacheEnabled :boolean
Whether or not the contents of templateUrl should be cached on first load for use with future instances of this View class (default: true)
Type:
- boolean
templateUrl :string
Template to load and apply to the View's element
Type:
- string
Methods
addEventListener(type, handler, scopeopt, priorityopt, onceopt) → {conbo.EventDispatcher}
Add a listener for a particular event type
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
type |
string | Type of event ('change') or events ('change blur') | ||
handler |
function | Function that should be called | ||
scope |
Object |
<optional> |
Options object (recommended) or the scope in which to run the event handler (deprecated) | |
priority |
number |
<optional> |
0 | The event handler's priority when the event is dispatached (deprecated) |
once |
boolean |
<optional> |
false | Should the event listener automatically be removed after it has been called once? (deprecated) |
- Inherited From:
- Source:
Returns:
A reference to this class instance
appendView(view) → {this}
Append this DOM element from one View class instance this class
instances DOM element
Parameters:
Name | Type | Description |
---|---|---|
view |
conbo.View | function | The View instance to append |
Returns:
- Type
- this
bindAll(…methodNameopt) → {this}
Scope all methods of this class instance to this class instance
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
methodName |
string |
<optional> <repeatable> |
Specific method names to bind (all will be bound if none specified) |
- Inherited From:
- Source:
Returns:
- Type
- this
bindView() → {this}
Automatically bind elements to properties of this View
Returns:
- Type
- this
Example
<div cb-bind="property|parseMethod" cb-hide="property">Hello!</div>
creationComplete()
Convenience method for conbo.ConboEvent.CREATION_COMPLETE event handler
declarations() → {void}
Declarations is used to declare instance properties used by this class
Parameters:
Type | Attributes | Description |
---|---|---|
* |
<repeatable> |
- Inherited From:
- Source:
Returns:
- Type
- void
destroy() → {void}
Clean everything up ready for garbage collection (you should override in your own classes)
- Inherited From:
- Source:
Returns:
- Type
- void
detach() → {this}
Take the View's element element out of the DOM
Returns:
- Type
- this
dispatchChange(propName) → {conbo.EventDispatcher}
Dispatch a change event for one or more changed properties
Parameters:
Name | Type | Description |
---|---|---|
propName |
string | The name of the property that has changed |
- Inherited From:
- Source:
Returns:
A reference to this class instance
dispatchEvent(event) → {conbo.EventDispatcher}
Dispatch the event to listeners
Parameters:
Name | Type | Description |
---|---|---|
event |
conbo.Event | The event to dispatch |
- Inherited From:
- Source:
Returns:
A reference to this class instance
hasEventListener(type, handleropt, scopeopt) → {boolean}
Does this object have an event listener of the specified type?
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
string | Type of event (e.g. 'change') | |
handler |
function |
<optional> |
Function that should be called |
scope |
Object |
<optional> |
Options object (recommended) or the scope in which to run the event handler (deprecated) |
- Inherited From:
- Source:
Returns:
True if this object has the specified event listener, false if it does not
- Type
- boolean
initialize() → {void}
Initialize (entry point) is called immediately after the constructor has completed
Parameters:
Type | Attributes | Description |
---|---|---|
* |
<repeatable> |
- Inherited From:
- Source:
Returns:
- Type
- void
initTemplate() → {this}
Initialize the View's template, either by loading the templateUrl
or using the contents of the template property, if either exist
Returns:
- Type
- this
loadTemplate(urlopt) → {this}
Load HTML template and use it to populate this View's element
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
url |
string |
<optional> |
The URL to which the request is sent |
Returns:
- Type
- this
preinitialize() → {void}
Preinitialize is called before any code in the constructor has been run
Parameters:
Type | Attributes | Description |
---|---|---|
* |
<repeatable> |
- Inherited From:
- Source:
Returns:
- Type
- void
prependView(view) → {this}
Prepend this DOM element from one View class instance this class
instances DOM element
Parameters:
Name | Type | Description |
---|---|---|
view |
conbo.View | The View instance to preppend |
Returns:
- Type
- this
querySelector(selector, deep) → {HTMLElement}
Uses querySelector to find the first matching element contained within the
current View's element, but not within the elements of child Views
Parameters:
Name | Type | Description |
---|---|---|
selector |
string | The selector to use |
deep |
boolean | Include elements in child Views? |
Returns:
The first matching element
- Type
- HTMLElement
querySelectorAll(selector, deep) → {Array}
Uses querySelectorAll to find all matching elements contained within the
current View's element, but not within the elements of child Views
Parameters:
Name | Type | Description |
---|---|---|
selector |
string | The selector to use |
deep |
boolean | Include elements in child Views? |
Returns:
All elements matching the selector
- Type
- Array
remove() → {this}
Remove and destroy this View by taking the element out of the DOM,
unbinding it, removing all event listeners and removing the View from
its Context.
You should use a REMOVE event handler to destroy any event listeners,
timers or other persistent code you may have added.
Returns:
- Type
- this
removeEventListener(typeopt, handleropt, scopeopt) → {conbo.EventDispatcher}
Remove a listener for a particular event type
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
string |
<optional> |
Type of event ('change') or events ('change blur'), if not specified, all listeners will be removed |
handler |
function |
<optional> |
Function that should be called, if not specified, all listeners of the specified type will be removed |
scope |
Object |
<optional> |
Options object (recommended) or the scope in which to run the event handler (deprecated) |
- Inherited From:
- Source:
Returns:
A reference to this class instance
templateComplete()
Convenience method for conbo.ConboEvent.TEMPLATE_COMPLETE event handler
toString() → {string}
String representation of the current class
- Overrides:
- Source:
Returns:
- Type
- string
unbindView() → {this}
Unbind elements from class properties
Returns:
- Type
- this