Pass an object with key value pairs for the attributes of the model
extends goog.events.EventTargetInstance Method Summary | |
addSchemaRules(?Object schema) adds more rules to the schema | |
alias(string newName, string oldName) Can be used to create an alias, e.g: model.alias('surname', 'lastName'); | |
bind((Array|null|string) name, ?Function fn, <Any Type> opt_handler) ⇒ number Allows easy binding of a model's attribute to an element or a function. bind('name', function(value), handler) allows you to run a function and optionally bind it to the handler. You can also pass in an array of names to listen for a change on any of the attributes. | |
bindAll(?Function fn, ?Object= opt_handler) ⇒ number bind to any change event | |
bindUnload(?Function fn, ?Object= opt_handler) ⇒ number | |
change() fires the change event for the model | |
change_() function called when a change is detected on the object. Call the model's .change() function to fire manually | |
dispose(boolean= opt_sync) | |
fetch((function ((Object|null), number, (mvc.Model|null)): ?=) opt_callback) reads an object fomr an external source using sync | |
format(string attr, ?Function fn) Can be used to change format returned when using get, e.g: model.format('date', function(date) {return date.toDateString();}); | |
get(string key, <Any Type> opt_default) ⇒ <Any Type> gets the value for an attribute | |
getBinder(string key) ⇒ ?Function can use this to construct setters. For instance if you would set a value like: model.set('location:latitude', number); you can make a convenience method like this: model.lat = model.getBinder('location:latitude'); and then you only need to use: model.lat(number); // to set var lat = model.lat(); // to get | |
getChanges() ⇒ ?Array.<string> returns object of changed attributes and their values | |
getCid() ⇒ string return local id | |
has(string key) ⇒ boolean | |
isNew() ⇒ boolean returns whether an ID has been set by the server | |
meta(string attr, ?Array.<string> require, ?Function fn) Can be used to make an attribute out of other attributes. This can be bound and will fire whenever a change is made to the required attributes e.g. model.meta('fullName', ['firstName', 'lastName'], function(firstName, lastName){ return firstName + " " + lastName; }); | |
parseSchemaFn_(<Any Type> fn) ⇒ ?Function used internally to parse strings and regexes in to functions | |
prev(string key) ⇒ <Any Type> returns the previous value of the attribute | |
reset(boolean= opt_silent) removes all attributes | |
revert(boolean= opt_silent) ⇒ ?mvc.Model reverts an object's values to it's last fetch | |
save() pushes the object to the sync | |
set((Object|null|string) key, <Any Type> opt_val, boolean= opt_silent) ⇒ boolean set either a map of key values or a key value | |
setSchema(?Object schema) sets the schema | |
setSync(?mvc.Sync sync) sets the sync for the model | |
setter(string attr, ?Function fn) | |
toJson() ⇒ !Object returns full copy of the attributes | |
unbind(number id) ⇒ boolean unbind a listener by id | |
unset(string key, boolean= opt_silent) ⇒ boolean |
Static Method Summary | |
create(?Object= opt_options) ⇒ ?mvc.Model instead of doing: model = new mvc.Model(options); you can do: mvc.Model.create(options); |