Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Captivate 10 firing "On Enter" JS before all DOM elements are constructed?

Participant ,
Jan 22, 2018 Jan 22, 2018

Hello!  I do not have Captivate 10 (still on v9) but one of the colleagues was upgraded recently and commented that the script that I wrote a while ago does not work with Captivate v10.

Part of the script is trying to access a text caption and read its innerHTML.  But apparently, when the function is executed immediately when you enter the slide, that element does not exist yet.  Running that same function slightly later (for example using setTimeout) works just fine.  Is this by design, or is this a bug? 

Thanks!

710
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Jan 23, 2018 Jan 23, 2018

I use a setInterval if I need to check something immediately. This happen a lot when manipulation the canvas elements. By the way, are you trying to get the text in a text caption? It is an image unless you are getting the accessibility paragraph.

in the onEnter event:

interval = setInterval( checkExists, 100, e );

and the function:

function checkExists( e )

{

if ( document.getElementById( 'barc' ) !== null )

{

  clearInterval( interval );

  interval = null;

  initSlide( e );

}

}

Translate
Community Expert ,
Jan 22, 2018 Jan 22, 2018

I cannot speak about JS, but there is defnitely a bug with some On Enter advanced actions as well for HTML5 output. That bug was logged more than 7 months ago, still not solution. Your problem is probably linked to that same bug.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 23, 2018 Jan 23, 2018

Thank you for replying! 

Could you tell me what sort of issues that bug creates? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 23, 2018 Jan 23, 2018

I had the problem that using micronavigation to replay a slide didn't work in HTML5 output, becasse the action On Enter didn't get done.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 22, 2018 Jan 22, 2018

This might help as workaround.  You could try wrapping your function into jquery's .ready function. It will only execute once all the DOM elements have been loading on the page. 

$(document).ready(function(){

YOUR FUNCTION'S ACTIONS HERE

});

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 23, 2018 Jan 23, 2018

Thanks for your suggestion! 

I'm afraid, however, that wouldnt wouldnt work, as the $(document).ready is already true by the time the On Load is executed (since On Load only runs when the page is loaded). 

I did try it, through, to be sure - it resulted in the same problem. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 23, 2018 Jan 23, 2018

I use a setInterval if I need to check something immediately. This happen a lot when manipulation the canvas elements. By the way, are you trying to get the text in a text caption? It is an image unless you are getting the accessibility paragraph.

in the onEnter event:

interval = setInterval( checkExists, 100, e );

and the function:

function checkExists( e )

{

if ( document.getElementById( 'barc' ) !== null )

{

  clearInterval( interval );

  interval = null;

  initSlide( e );

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 23, 2018 Jan 23, 2018
LATEST

Thanks - great suggestion! 

I am targeting the accessibility layer.  Everything worked great until Captivate 10. 

Thank you again for help!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources