Does knockout perform model binding asynchronously? if so, how do I
prevent it?
In the following code I am updating my knockout model property
SearchResults, and then I am recomputing the size of all the columns in my
html. I know the _resizeColumns function works correctly. However it is
being run before the DOM has been updated with the search results. I have
verified that _resizeColumns is being called by updating the
background-color on all divs with yellow. The divs that existed prior to
the model update are getting set to yellow, but the search results are
not.
$.ajax({
type: 'POST',
url: 'foo.com',
data: postData,
contentType: 'application/json; charset=utf-8',
dataType: 'json',
processData: true,
success: function(data) {
model.SearchResults(data.d); // updates the DOM with the search
results via knockout.js
_resizeColumns(); // does not resize the columns because
they haven't been added to the DOM yet
},
error: function() { alert('error'); }
});
The search results do get added to the DOM, it is just after my call to
_resizeColumns
No comments:
Post a Comment