javascript - In a Durandal viewmodel, the view isn't always attached when viewAttached() called -


i have viewmodel in durandal has function viewattached().

according the docs supposed called after view attached dom.

in function have jquery selector element in view being attached:

function viewattached() {     console.log( $("#myviewid").length ); } 

most of time correctly "1" printed console, maybe 10% of time 0. view not yet attached dom.

has else had problem?

viewattached gets produced dom sub tree passed in argument.

so either change code along line

function viewattached(view) {     console.log( $(view).length ); } 

if want wrap whole view jquery or

function viewattached(view) {     console.log( $(view).find('mysubselector').length ); } 

if need work specific sub tree elements.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -