Forum Discussion

nick_pook's avatar
nick_pook
Community Member
3 months ago
Solved

Get object ID of the object that was part of the trigger

Hello All- I am guessing this is going to need to be a feature request since I couldn't find anything about it but figured I wad ask here first before submitting one just in case.

I am looking for a way to automatically get the object ID of the object that was part of the trigger. Storyline already knows what object is being interacted with (because the user clicked on it, did something to make the state change, etc...) so I want to be able to just use "triggerObjectID" in my code. I am building out some custom buttons that have some different actions on them using the new JavaScript API. I would like to make one button (with all the states) and then duplicate it multiple times without needing to go in and change the object ID for the action of each trigger on each state of each instance of the button.

Any suggestions?

  • Hi nick_pook​ I'm not sure of the context of your usage, but could you use any regular smegular JS to get the object ID through the data-model-id property of the element?

    document.querySelectorAll('[data-model-id]').forEach(el => {
      el.addEventListener('click', () => {
        console.log(el.getAttribute('data-model-id'));
      });
    });

     

2 Replies

  • Hi nick_pook​ I'm not sure of the context of your usage, but could you use any regular smegular JS to get the object ID through the data-model-id property of the element?

    document.querySelectorAll('[data-model-id]').forEach(el => {
      el.addEventListener('click', () => {
        console.log(el.getAttribute('data-model-id'));
      });
    });

     

    • nick_pook's avatar
      nick_pook
      Community Member

      This did work for my use case. It does feel like a workaround for something that should be pretty easy since Storyline already knows what was interacted with. 

      Thank you for your help!