Please consider the following ViewModel snippet:
var id, given1, given2;
$.get("testSynUfGet.aspx", null, function (data) {
id = data.id;
given1 = data.given1;
given2 = data.given2;
}, 'json');
//alert('here');
ko.applyBindings(new viewModel(id, given1, given2));
It seems that my ajax call through $.get
is too slow or the ko.applyBindings()
is too fast. Either way, it seems that knockout can only properly bind if I uncomment the line alert('here');
.
If I leave it commented, none of the controls get populated.
Any ideas, folks?
The only work around I could think of is to do .applyBindings
as part of the function callback in $.get
like this:
$.get("testSynUfGet.aspx", null, function (data) {
ko.applyBindings(new viewModel(data.id, data.given1, data.given2));
}, 'json');