2
I’m having a problem in a simple test with Knockoutjs in conjunction with Mootools:
<div>
<select data-bind="foreach: animais">
<option data-bind="text: nome, value: id"></option>
</select>
</div>
var Animal = new Class({
initialize: function(id, nome) {
this.self = this;
self.id = id;
self.nome = nome;
}
});
viewModel = new Class({
initialize: function(animais) {
this.self = this;
self.animais = animais;
}
});
ko.applyBindings(new viewModel([
new Animal(1, "Cachorro"),
new Animal(2, "Gato"),
new Animal(3, "Macaco")
]));
Rodem no Jsfiddle: http://jsfiddle.net/p6nyr4nq/1/
Interestingly, select contains "Monkey" repeated 3 times.
Andrey, the right thing would be to use the
bindingHandler
options
, I tried using here: http://jsfiddle.net/p6nyr4nq/6/, but since I don’t know Mootools, I don’t know how it works to create and organize yourViewModel
...– Wakim
Can you explain better what you want to do? You are exporting the
self
to the global space... your use of the Mootools Class is not correct. If you explain it better you can help...– Sergio