I implemented a ViewModel in Durandal with a function called viewAttached()
.
As mentioned in the documentation, this function is supposed to be executed after the view is attached to the DOM.
Within my function, there is a jQuery selector targeting an element in the View that is being attached:
function viewAttached() {
console.log( $("#myViewId").length );
}
Most of the time, it correctly returns "1" to the console, but occasionally around 10% of the time, it returns 0. This indicates that the view is not yet fully attached to the DOM.
Has anyone encountered a similar issue?