Class: kb.Observable
Defined in: | src/core/observable.coffee |
Overview
Base class for observing model attributes.
Examples:
How to create a ko.CollectionObservable using the ko.collectionObservable factory.
var ContactViewModel = function(model) {
this.name = kb.observable(model, 'name');
this.number = kb.observable(model, { key: 'number'});
};
var model = new Contact({ name: 'Ringo', number: '555-555-5556' });
var view_model = new ContactViewModel(model);
How to create a kb.Observable with a default value.
var model = Backbone.Model({name: 'Bob'});
var name = kb.observable(model, {key:'name', default: '(none)'}); // name is Bob
name.setToDefault(); // name is (none)
Instance Method Summary
- # (void) destroy() Required clean up function to break cycles, release view models, etc.
- # (kb.CollectionObservable|kb.ViewModel|ko.observable) value()
- # (kb.TYPE_UNKNOWN|kb.TYPE_SIMPLE|kb.TYPE_ARRAY|kb.TYPE_MODEL|kb.TYPE_COLLECTION) valueType()
Constructor Details
#
(ko.observable)
constructor(model, key_or_info, options, _vm = {})
Note:
the constructor does not return 'this' but a ko.observable
Used to create a new kb.Observable.
Instance Method Details
#
(void)
destroy()
Required clean up function to break cycles, release view models, etc. Can be called directly, via kb.release(object) or as a consequence of ko.releaseNode(element).
#
(kb.CollectionObservable|kb.ViewModel|ko.observable)
value()
#
(kb.TYPE_UNKNOWN|kb.TYPE_SIMPLE|kb.TYPE_ARRAY|kb.TYPE_MODEL|kb.TYPE_COLLECTION)
valueType()