Last active
December 14, 2015 19:39
-
-
Save kmorcinek/5138476 to your computer and use it in GitHub Desktop.
Usefull Knockoutjs stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ko.dataFor | |
ko.computed({ //}, viewModel); - second parameter as a context. | |
viewModel.whoAmI = function() { alert(this.name);}.bind(viewModel); | |
<script type="text/html" id="person-template"> | |
<pre data-bind="text: ko.toJSON($root, null, 2)"></pre> | |
click: function() { viewModel.removeGift($data) } | |
valueHasMutated () | |
this.count(this.count() + 1); | |
data-bind=”if: ...” rerender the content each time, observed value has changed. | |
Initialize() inside construktor. | |
do not operate on array element by element | |
//replace the contents of the observableArray | |
this.otherItems(newData); | |
ko.subscribable.fn.logIt | |
http://www.knockmeout.net/2013/06/knockout-debugging-strategies-plugin.html | |
ko.observable.fn.toString = function() { | |
return "observable: " + ko.toJSON(this(), null, 2); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment