JavaScript Triggers
Sep 14, 2015
By
Doug Mattson
I have a JavaScript trigger setup and it works great (running from my Public Dropbox folder)! However, when I add a second JavaScript trigger on a different slide in a different scene and publish, neither trigger works. I then take out the second trigger, republish and the first trigger works again. Can I use more than one JavaScript trigger in a single module?
Doug
14 Replies
Hi Doug,
You can certainly use more than one trigger with Javascript, but I'd want to know where/how you were testing your published output? You'll want to confirm you're testing in the intended environment as detailed here. Also, there is some additional information on working with Javascript here that you'll want to review. Since it's not something I can offer additional support on, if you continue to have difficulty you may want to share the .story file or code here so that the community can take a look at what you've set up.
There is likely an error in the second trigger, an error in any javascript rigger will stop them all working.
Thanks Phil for weighing in here - Doug, let us know if there is anything else you need.
Thanks Phil!
There was an error in the code of the JavaScript in the second trigger. Fixed it and all of the JS triggers are working. Thank you, Phil!!
Doug
Thanks for that update Doug!
Been digging through a course today as well, just to find 1 JS error in a 81 slide course filled with JS. Not very entertaining I can tell you.
Ended up removing a
'
<- to make everything work again.Not a good situation, I find it is good practice to test each javascript trigger as you insert it.
I know this means uploading and testing, it does mean that you know when your javascript has broken and which trigger it was.
We have multiple people working on several projects at the same time, sometimes it's just bound to go wrong. But I 100% agree with that, I wish there was a way to test it without having to do the publishing part.
Hi Bob,
I know it's something others have shared their thoughts on in the forum of a feature request, as a way to test the Javascript triggers prior to publishing - I'm not sure what that would look like, but feel free to share your thoughts here with our team.
I would like an editor that picks up errors in javascript, I often paste the code into an editor to ensure it has no syntax errors
A basic wizard that writes your code for you would also be a nice feature for users who are not happy eating code.
https://jsfiddle.net/ is something i'd use to write my code in, where i would just use a alert(variable); to make sure i get the desired output. But of course ideally you would want to test your JS in articulate directly. @Ashley I imagined the javascript to just "work" when you preview your course. I don't know the possibilities in that though :)
Me neither Bob - but that's what our product development team is for! ;-)
This discussion is closed. You can start a new discussion or contact Articulate Support.