I have just come across a problem which is quite bizarre, where I have multiple applyBindings() but they all target different elements. Now this all used to work fine, as it would all happen once all resources were loaded (a yepnope complete callback), however now its happening based on an event being raised (from our internal event system) it seems to have a weird error (saying view model does not have observable, but its because its not looking in the right one).
The issue is that the last binding seems to for some reason overwrite all other bindings, so if I had 4 elements with unique ids and 4 view models each which are bound to their coresponding element, so I would expect the bindings to occur like so:
element_a -> view_model_a
element_b -> view_model_b
element_c -> view_model_c
element_d -> view_model_d
However for some reason the bindings seem to change when view_model_d is bound so they all become:
element_a -> view_model_d
element_b -> view_model_d
element_c -> view_model_d
element_d -> view_model_d
As I said this used to work fine, but since we turned to an asynchronous way of applying the bindings it seems to be a bit broken, all of the bound elements are in the html and self contained (i.e none of them are dynamically injected and dont overlap in the DOM). Also when debugging in firebug the viewmodels and the elements are correct and not undefined, which could have explained why the last one called would overwrite all others.
I would try and do a jsfiddle but due to the complex nature of the project and the external templates and dependencies it would not be possible.
All things point to me doing something wrong, not KnockoutJS, but I cannot understand why it used to work fine the only thing that has changed is the order and timing of the apply bindings.
Anyone ever seen applyBindings bleeding over into other elements or overwriting previous bindings before?