Class: Comment

XM. Comment

Base class for use on comment subclasses.

new Comment()

Source:

Extends

Members

sourceName

The name of the source used in conjunction with `CommentTypeSource` to determine which comment types are available in a given comment subclass.
Source:

Methods

_fetchHelper()

Prepare fetch. TODO sync() alone should handle all of this stuff. fetch() is not a Backbone customization point by design.
Inherited From:
Source:

bindEvents()

A function that binds events to functions. It can and should only be called once by initialize. Any attempt to call it a second time will throw an error.
Inherited From:
Source:

build()

Overload: assume that anything calling this function is doing so because it is building a model for a relation. In that case set the `isFetching` option is true which will set it in a `BUSY_FETCHING` state when it is created.
Inherited From:
Source:

destroy() → {Object|Boolean}

Reimplemented to handle state change and parent child relationships. Calling `destroy` on a parent will cause the model to commit to the server immediately. Calling destroy on a child relation will simply mark it for deletion on the next save of the parent.
Inherited From:
Source:
Returns:
Type
Object | Boolean

fetch(Options) → {Object}

Parameters:
Name Type Description
Options Object
Inherited From:
Source:
Returns:
Request
Type
Object

fetchId() → {Object}

Set the id on this record an id from the server. Including the `cascade` option will call ids to be fetched recursively for `HasMany` relations.
Inherited From:
Source:
Returns:
Request
Type
Object

fetchRelated(key, options, update) → {Array}

Retrieve related objects.
Parameters:
Name Type Description
key String The relation key to fetch models for.
options Object Options for 'Backbone.Model.fetch' and 'Backbone.sync'.
update Boolean Whether to force a fetch from the server (updating existing models).
Inherited From:
Source:
Returns:
An array of request objects.
Type
Array

findOrCreate()

Overload: Need to handle status here
Inherited From:
Source:

getClass() → {XM.Model}

Returns the current model prototype class.
Inherited From:
Source:
Returns:
Type
XM.Model

getParent(Get) → {XM.Model}

Return the parent model if one exists. If the `getRoot` parameter is passed, it will return the top level parent of the model hierarchy.
Parameters:
Name Type Description
Get Boolean Root
Inherited From:
Source:
Returns:
Type
XM.Model

initialize()

Called when model is instantiated.
Inherited From:
Source:

isReadOnly(attribute) → {Boolean}

Return whether the model is in a read-only state. If an attribute name is passed, returns whether that attribute is read-only. It is also capable of checking the read only status of child objects via a search path string.

        // Inquire on the whole model
        var readOnly = this.isReadOnly();

        // Inquire on a single attribute
        var readOnly = this.isReadOnly("name");

        // Inquire using a search path
        var readOnly = this.isReadOnly("contact.firstName");
      
Parameters:
Name Type Description
attribute String
Inherited From:
Source:
Returns:
Type
Boolean

obtainLock()

Attempt to obtain lock.
Inherited From:
Source:
Fires:
  • lock:obtain

parse(Response)

Recursively checks the object against the schema and converts date strings to date objects.
Parameters:
Name Type Description
Response Object
Inherited From:
Source:

releaseLock()

Release lock.
Inherited From:
Source:
Fires:
  • lock:release

renewLock()

Attempt to renew lock.
Inherited From:
Source:
Fires:
  • lock:renew

revert()

Revert a model back to its original state the last time it was fetched.
Inherited From:
Source:

revertStatus()

Revert the model to the previous status. Useful for reseting status after a failed validation. param {Boolean} - cascade
Inherited From:
Source:

save()

Reimplemented.
Inherited From:
Source:

set(Key, Value, Options)

Overload: Don't allow setting when model is in error or destroyed status, or updating a `READY_CLEAN` record without update privileges.
Parameters:
Name Type Description
Key String | Object
Value String | Object or Options
Options Objecw
Inherited From:
Source:

setStatus(Status)

Set the status on the model. Triggers `statusChange` event. Option set to `cascade` will propagate status recursively to all HasMany children.
Parameters:
Name Type Description
Status Number
Inherited From:
Source:

setValue()

Set a value(s) on attributes if key(s) is/are in schema, otherwise set on `meta`. If `meta` is null then behaves the same as `setIfExists`. Supports path strings.
Inherited From:
Source:

toJSON()

Overload: Delete objects marked as destroyed from arrays and convert dates to strings. Add support for 'includeNested' option that will output JSON with nested toOne objects when specified.
Inherited From:
Source:

validate(Attributes, Options)

Default validation checks `attributes` for:
* Data type integrity.
* Required fields.

Returns `undefined` if the validation succeeded, or some value, usually an error message, if it fails.

Parameters:
Name Type Description
Attributes Object
Options Object
Inherited From:
Source: