I am wondering if it is possible with knockoutjs to pass arguments when binding.
I am binding a list of checkboxes and would like to bind to a single computed observabl
Without knowing the specifics, it seems like what you should be doing is defining a ko.observableArray or computed array value
HTML:
myprop:
JS:
$(function() {
function Model() {
this.self = this
self.myprop = ko.observable(14)
self.bits = [1, 2, 4, 8, 16, 32, 64, 128]
self.selections = ko.computed(function() {
return self.bits.map(function(bit) {
console.log(myprop() & bit)
return {
value: bit,
selected: (myprop() & bit) == bit
}
})
})
}
ko.applyBindings(new Model())
})
and not passing values from the markup to define the model state