Class JsModel#instance
A single instance of a Model
Defined in: js_model.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Instances of a Model
|
Field Attributes | Field Name and Description |
---|---|
<static> |
JsModel#instance.parentClass
instances get their parentClass assigned this model
|
Method Attributes | Method Name and Description |
---|---|
<static> |
JsModel#instance.destroy()
destroy this instance - works just like rails #destroy will fire off the destroy event as well
controllers will receive this event by default
|
<static> |
JsModel#instance.get(key)
Use this to retreive attributes on an object (rather than accessing them directly);
|
<static> |
JsModel#instance.observe(key, func)
listen to an attribute of a model
|
<static> |
JsModel#instance.primaryKey()
You should always use this to refer to instances.
|
<static> |
JsModel#instance.set(key, value)
Use this to set attributes of an instance (rather than set them directly).
|
<static> |
JsModel#instance.touch(key)
Use to manually fire a change event on an attribute.
|
<static> |
JsModel#instance.updateAttributes(obj)
Take an Object literal and update all attributes on this instance
|
Field Detail
<static>
{JsModel}
JsModel#instance.parentClass
instances get their parentClass assigned this model
Method Detail
<static>
JsModel#instance.destroy()
destroy this instance - works just like rails #destroy will fire off the destroy event as well
controllers will receive this event by default
<static>
JsModel#instance.get(key)
Use this to retreive attributes on an object (rather than accessing them directly);
modelInstance.set('myAttr', 'foo'); modelInstance.get('myAttr', 'foo');
- Parameters:
- {String} key
<static>
JsModel#instance.observe(key, func)
listen to an attribute of a model
- Parameters:
- key
- func
- Returns:
- an EventHandler subscription object
- See:
- MBX.EventHandler
<static>
JsModel#instance.primaryKey()
You should always use this to refer to instances.
Model.find uses this to grab objects from the instances
- Returns:
- returns the primaryKey of the instance
- See:
- JsModel.find
<static>
JsModel#instance.set(key, value)
Use this to set attributes of an instance (rather than set them directly).
It will automatically create events that will be relevant to controllers
modelInstance.set('myAttr', 'foo'); modelInstance.get('myAttr', 'foo');
- Parameters:
- {String} key
- the key of the attribute
- value
- the value to be assigned to the attribute
<static>
JsModel#instance.touch(key)
Use to manually fire a change event on an attribute.
modelInstance.touch("myAttr");
- Parameters:
- {String} key
- the key of the attribute you want to fire the enent on
<static>
JsModel#instance.updateAttributes(obj)
Take an Object literal and update all attributes on this instance
- Parameters:
- {Object} obj
- the attributes to update as key, value