Knockout.JS v3.3.0
|
|
See elsewhere
|
1
|
See footnote
|
|
?
|
Optional
|
R
|
Ruby on Rails
|
var *vm* = function(value) {
this.*variable* = ko.observable(value);
};
ko.applyBindings(new *vm*('...'), DOM^?^);
<div data-bind=”bindings”>html</div> |
<!-- ko bindings -->html<!-- /ko --> |
<script type="text/html" id="T">html</script> |
if in { 'if': ... } bindings.
.isObservable() |
.isWritableObservable() |
.isComputed() |
.valueHasMutated() |
.subscribe(function(v) {}, trg1?, event2?) : s |
|
.notifySubscribers(currentvalue) |
|
|
s
.dispose() |
|
this.change (default) or beforeChange.
() : value |
(value) : vm |
() : []1 |
([]) : vm |
.pop() : item |
.push(item) |
.shift() : item |
.unshift(item) |
.remove(item) |
.removeAll() |
.indexOf(item) : -/#1 |
.reverse() |
.slice(s, e?) : [] |
.splice(s, l?, …?) : [] |
.sort(function(a, b)? : -/0/+2) |
|
.destroy(item)R |
.destroyAll() R |
().length. Get item: ()[index]
() : value |
ko.pureComputed if only observables.
text: string |
html: string |
css: { class:bool, …} |
style: { css:value, …} |
attr: { attribute:value, … } |
|
visible: bool |
template: string/{} |
name: string |
nodes: [DOM, …] |
data: [] |
if: bool |
foreach: [] |
as: string |
afterRender: function([DOM], context) |
|
afterAdd: function |
beforeRemove: function |
foreach: []/{} |
with: observable |
if: bool |
ifnot: bool |
component: observable |
|
data: [] |
as: string |
afterRender: function |
|
afterAdd: function |
beforeRemove: function |
beforeMove: function |
afterMove: function |
includeDestroyedR: bool |
|
click: function |
event: { event: function } |
submit: function |
|
value: string |
textinput:1 string |
enable: bool |
disable: bool |
hasFocus: bool |
checked: bool |
options: []/{} |
uniqueName: bool |
optionsCaption: string |
|
optionsText: string |
optionsValue: string |
optionsAfterRender: function |
|
selectedOptions1: [] |
valueAllowUnset: bool |
optionsIncludeDestroyedR: bool |
|
$root : vm |
$component : vm |
$parent : vm |
$parents[index] : vm |
$data : vm |
$rawData : vm |
$element : DOM |
$index1 : integer |
$componentTemplateNodes : DOM array |
|
$context : context |
$parentContext : context |
foreach loops.
this.value = ko.observable();
this.double = ko.pureComputed({
read: function () { return this.value * 2; },
write: function(v) { this.value(v / 2); },
owner: this^**?**^
});
.extend({ rateLimit: { timeout: milliseconds, method: method1? } }) |
.extend({ notify: 'always' }); |
notifyAtFixedRate/notifyWhenChangesStop
ko.extenders.log = function(target, option) {
target.subscribe(function(newValue) {
console.log(option + ": " + newValue);
});
return target;
};
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.