I'm using KnockoutJS in conjunction with MooTools, but I'm having trouble with Request .
<div class="form-group">
<select data-bind="options: classificacoes, optionsText: ds_classificacao, optionsValue: id"></select>
</div>
<script>
ko.applyBindings( new App.viewModels.selectsProcedimentos() );
</script>
App.requests.classificacoes = new Request.JSON({
url: "/classificacoes.json",
method: "get"
});
App.viewModels.selectsProcedimentos = new Class({
initialize: function() {
this.classificacoes = ko.observableArray([]);
App.requests.classificacoes.send({
onSuccess: function(classificacoes) {
this.classificacoes.push(classificacoes);
alert("baixou");
}
});
alert("initialize");
}
});
What happens here is that initialize
is fired, but the onSuccess
method is not, <select>
is empty. However in the network tab of the development tools you can see that JSON is downloaded. There are no errors in the console.