new OldView(viewName)
The view constructor.
Parameters:
Name | Type | Description |
---|---|---|
viewName |
- Source:
Methods
bind(selector, options)
Binds a selector to the insert, update and delete events of a particular
view and keeps the selector in sync so that updates are reflected on the
web page in real-time.
Parameters:
Name | Type | Description |
---|---|---|
selector |
String | The jQuery selector string to get target elements. |
options |
Object | The options object. |
- Source:
bindRender(bindSelector, domHandleropt)
Renders a bind view data to the DOM.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
bindSelector |
String | The jQuery selector string to use to identify the bind target. Must match the selector used when defining the original bind. | |
domHandler |
function |
<optional> |
If specified, this handler method will be called with the final HTML for the view instead of the DB handling the DOM insertion. |
- Source:
bindSortDom(selector, itemArr)
Sorts items in the DOM based on the bind settings and the passed item array.
Parameters:
Name | Type | Description |
---|---|---|
selector |
String | The jQuery selector of the bind container. |
itemArr |
Array | The array of items used to determine the order the DOM elements should be in based on the order they are in, in the array. |
- Source:
count() → {Number}
Returns the number of documents currently in the view.
- Source:
Returns:
- Type
- Number
db(db) → {*}
Gets / sets the DB the view is bound against. Automatically set
when the db.oldView(viewName) method is called.
Parameters:
Name | Type | Description |
---|---|---|
db |
- Source:
Returns:
- Type
- *
drop() → {boolean}
Drops a view and all it's stored data from the database.
- Source:
Returns:
True on success, false on failure.
- Type
- boolean
find() → {*}
Queries the view data. See Collection.find() for more information.
- Source:
Returns:
- Type
- *
from(collection) → {*}
Gets / sets the collection that the view derives it's data from.
Parameters:
Name | Type | Description |
---|---|---|
collection |
* | A collection instance or the name of a collection to use as the data set to derive view data from. |
- Source:
Returns:
- Type
- *
insert() → {*}
Inserts into view data via the view collection. See Collection.insert() for more information.
- Source:
Returns:
- Type
- *
isBound(selector) → {boolean}
Returns true if the selector is bound to the view.
Parameters:
Name | Type | Description |
---|---|---|
selector |
String | The jQuery selector string to identify the bind to check for. |
- Source:
Returns:
- Type
- boolean
primaryKey() → {String}
Gets the primary key for this view from the assigned collection.
- Source:
Returns:
- Type
- String
query(queryopt, refreshopt) → {*}
Gets / sets the query being used to generate the view data.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
query |
Object |
<optional> |
The query to set. |
refresh |
Boolean |
<optional> |
Whether to refresh the view data after this operation. Defaults to true. |
- Source:
Returns:
- Type
- *
queryAdd(obj, overwrite, refreshopt)
Add data to the existing query.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
Object | The data whose keys will be added to the existing query object. | |
overwrite |
Boolean | Whether or not to overwrite data that already exists in the query object. Defaults to true. | |
refresh |
Boolean |
<optional> |
Whether or not to refresh the view data set once the operation is complete. Defaults to true. |
- Source:
queryData(queryopt, optionsopt, refreshopt) → {*}
Gets / sets the query that the view uses to build it's data set.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
query |
Object |
<optional> |
|
options |
Boolean |
<optional> |
An options object. |
refresh |
Boolean |
<optional> |
Whether to refresh the view data after this operation. Defaults to true. |
- Source:
Returns:
- Type
- *
queryOptions(optionsopt, refreshopt) → {*}
Gets / sets the query options used when applying sorting etc to the
view data set.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> |
An options object. |
refresh |
Boolean |
<optional> |
Whether to refresh the view data after this operation. Defaults to true. |
- Source:
Returns:
- Type
- *
queryRemove(obj, refreshopt)
Remove data from the existing query.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
Object | The data whose keys will be removed from the existing query object. | |
refresh |
Boolean |
<optional> |
Whether or not to refresh the view data set once the operation is complete. Defaults to true. |
- Source:
refresh()
Refreshes the view data and diffs between previous and new data to
determine if any events need to be triggered or DOM binds updated.
- Source:
remove() → {*}
Removed from view data via the view collection. See Collection.remove() for more information.
- Source:
Returns:
- Type
- *
unBind(selector) → {Collection}
Un-binds a selector from the view changes.
Parameters:
Name | Type | Description |
---|---|---|
selector |
String | The jQuery selector string to identify the bind to remove. |
- Source:
Returns:
- Type
- Collection
update() → {*}
Updates into view data via the view collection. See Collection.update() for more information.
- Source:
Returns:
- Type
- *