Created
September 19, 2012 13:21
-
-
Save cleytonferrari/3749656 to your computer and use it in GitHub Desktop.
Usando knockout js com checkboxes sem template
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
<ul data-bind="foreach: items"> | |
<li> | |
<input type="checkbox" data-bind="attr: { value: id }, checked: $root.checked" /> | |
<span data-bind="text: descricao"></span> | |
</li> | |
</ul> | |
<hr/> | |
<div data-bind="text: ko.toJSON($root)"></div> |
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
var ViewModel = function() { | |
var self = this; | |
this.items = ko.observableArray([ | |
{ id: "1", descricao: "Leitura" }, | |
{ id: "2", descricao: "Gravação" }, | |
{ id: "3", descricao: "Escrita" }, | |
{ id: "4", descricao: "Nenhuma" } | |
]); | |
this.checked = ko.observableArray(["2","4"]); | |
}; | |
ko.applyBindings(new ViewModel()); | |
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment