Last active
August 29, 2015 14:15
-
-
Save keepitsimple/38870eba596608c75437 to your computer and use it in GitHub Desktop.
Knockout.js 'valueInit' binding (initialize value from html markup)
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.bindingHandlers.valueInit = | |
init: (element, valueAccessor) -> | |
property = valueAccessor() | |
if !ko.isWriteableObservable(property) | |
throw new Error 'Knockout "valueInit" binding expects an observable.' | |
property element.value | |
#html example | |
#<input data-bind="value: message, valueInit: 'Hello world'" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment