Skip to main content
Known Participant
July 28, 2020
Question

How do I hide and show objects on master slides with JavaScript in a fluid box project?

  • July 28, 2020
  • 2 replies
  • 347 views

I am trying to work out how to show and hide objects on master slides via JavaScript.

cp.hide("myObject); works but I then cannot show it with cp.show("myObject") as recommended in the documentation.

It looks like once hidden it is gone! If I enter document.getElementById("myObject"); in the browser console null is returned. I have seen a similar post on StackOverflow that was not resolved.

I have tried the same with an object added to a slide rather than master slide and get the same behaviour.

What I am trying to do is create custom navigation buttons in a responsive project using fluid boxes to overcome the serious limitations of the built-in Captivate playbar. It is proving to be far from straightforward. I hope someone can help!

    This topic has been closed for replies.

    2 replies

    Stagprime2687219
    Legend
    July 29, 2020

    Are you changing slides?

    Unless you set the navigation buttons to show for the rest of the project, each object will have a new ID on each new slide and so you'll hide and show the same button however many slides ago if you use the same code. So either modify your onEnter code to reflect the new ID for each page or show the buttons for the rest of the project so that the same ID can be used.

     

     I will be honest and say that I don't work with responsive projects so I am unsure about any idiosyncrasies that might interfere with what you're trying to do or not.

    Known Participant
    July 29, 2020

    Thank you both for your help.

    I tried "Rest of slide" for buttons but this falls apart with responsive projects and fluid boxes.

    I have worked around this by using a combination of the playbar, hiding the playbar thumbnail, using CPExtra to prevent scrubbing, and some SVGs as buttons on a master slide to allow the user to return to the beginning of the slide, reverse and go forward in the slide. This requires a combination of advanced actions and JavaScript.

    Until such time as a slider is available for the slide timeline like that for event videos (or I can work out how to implement one that will work placed on a master slide in a responsive project with fluid boxes) this will do.

    Lilybiri
    Legend
    July 28, 2020

    Just pop in to tell you that I never need JS to create custom navigation and toggle buttons. But will leave you to the JS experts, know that it is 'dangerous' to offer easier ways. 🙂