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

How do I use JavaScript to find a slide number using slide label?

Engaged ,
Oct 12, 2016 Oct 12, 2016

Hello,

In short, I would like to loop through the slides on a user interaction, find the slide with a particular label/title, get its corresponding slide number, and jump to that particular slide number.

I know how to find the correct slide object on the cp.model.data object, but this slide object doesn't seem to have the slide number on it.

Any help will be appreciated!

1.1K
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 ,
Oct 12, 2016 Oct 12, 2016

Does it have to be by JS? With an action you can jump to a slide using its label or its number.

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 ,
Oct 12, 2016 Oct 12, 2016

Really? Didnt know this... i knew you could use a number. Ill have to look

at this later...

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 ,
Oct 12, 2016 Oct 12, 2016

I am a labeling freak and always label slides and most objects. I never use a slide number in any action. At the same time you already have labels that will be used in the TOC, which I'll use in most projects and prefer over a playbar for navigation reasons.

Although I appreciate JS in some circumstances (like using an array, formatting a number, having a random number) there is quite a lot that can be done with advanced or shared actions that is much easier, at least if you are not a great programmer like TLCMediaDesign

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 ,
Oct 13, 2016 Oct 13, 2016

Hi Lilybiri,

I think there may have been a misunderstanding.  I know that you can jump to a slide number / label with an action, but I would like Captivate / JS to dynamically figure out what that slide is.

Scenario - I have a button on my master that should always take the user to a slide with the label "Reference" when they press it.  The issue is that as I work on my project the slide number for this "Reference" slide is always changing, and I dont want to have to adapt the action each time. Instead, I want JS to loop through the slides, figure out where the slide with the label Reference is, and then take the user there.  Once I set that up, I'll never have to adapt any actions again and can use the same code over different projects.

I know how to do this, though, with some help from TLCMediaDesign.  : )

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 ,
Oct 13, 2016 Oct 13, 2016

That is exactly the reason why I never use a slide number in any advanced action. The slide label will never change. This means that 'Jump to Reference' command on the master slide will always navigate to the correct slide, whatever its slide number is. AFAIK there is no misunderstanding at all on my part. I just found it very cumbersome to have to write a looping JS for such a pretty simple work flow. KISS is one of my motos, and this is clearly a situation where advanced actions are much easier.

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 ,
Oct 13, 2016 Oct 13, 2016

Oh, ok.  Then I guess I do not know how to jump to a slide by using the label.  When I click select "Jump to Slide" On Success, the drop down box below gives me a selection of slides.  I always thought when I chose one, the action is bound to that slide number.  Or is it bound to the label? 

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 ,
Oct 13, 2016 Oct 13, 2016

It's bound to that specific slide.  If after creating the action you move the slide do a different position in the slide order, the action is updated to still point to that same slide.  If you change the label, the action is updated to show that new label.

The same principle applies to objects that you reference in an action.

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 ,
Oct 13, 2016 Oct 13, 2016

Ok. Got it. Thanks!

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 ,
Oct 13, 2016 Oct 13, 2016
LATEST

Only place where you have to be careful is for D&D objects: do not change the names of the objects after creation of the D&D because you'll lose the links between Drag sources and Drop targets. I have no idea why.

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
Adobe Employee ,
Oct 12, 2016 Oct 12, 2016

You can use the event emitter. https://helpx.adobe.com/captivate/using/common-js-interface.html to track slide enter / exit etc. I think you'd also need to use a dummy button inside captivate with the model.data to do the page jump. LMK if you need an example.

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