Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : Is there a way to have can.view call a callback function when an EJS template is actually rendered and visible on screen?

$
0
0
Here is a structure that works for my app in Google Chrome.
I did not check it in other browsers.
  1. function initDlg( )
  2. {
  3. // listen to DOMNodeInserted to finalize the dialog after it is inserted into the DOM
  4. document.addEventListener( 'DOMNodeInserted', finalizeDialog );

  5. // render dialog modal and display it
  6. dialog = new cDialog( '#dialogs', { params . . . } );
  7. }

  8. function finalizeDialog( e )
  9. {
  10. if( e.srcElement.id == 'tDialogWrapper' ) {
  11. document.removeEventListener( 'DOMNodeInserted', finalizeDialog );
  12. // do here what you need to do after the dialog is inserted into the DOM
  13. }
  14. }

Viewing all articles
Browse latest Browse all 3491

Trending Articles