In certain instances when embedding our Pathways One product, your developer may want to get feedback on the status of a Pathways widget. With our new callback feature this is now possible.
We have added a new feature within Pathways One that gives your developer some additional information as to the load status of the widget. This could be particularly useful if they want to understand when the data within Pathways One has loaded.
A good example of this could be when using our auto-mapping embed option. Your developer may want to know if an instance of Pathways has been mapped for the page being viewed so they can display additional HTML around the Pathways widget - such as a title, container or other graphical elements.
(Note that when a Pathways instance has not been mapped, there will be no visible reference to Pathways on the page.)
To make this work your developer can write some code that will listen for a callback from the Pathways widget that will inform on its status. Then based on the response, they can choose to run a particular action.
In the auto-mapping example, if a Pathways instance is mapped to the page being viewed the response from the callback function would be “Pathways subject loaded” - at this point the developer could choose to show any additional HTML elements required. If the response was “No automapped subject found” then your developer could choose to leave certain elements hidden.
To make this work, your developer should add an attribute “data-callback” to your Pathways div element with the name of your Javascript function to call.
The callback function returns the ID of the Pathways element and one of the following response messages:
- No automapped subject found
- Pathways subject loaded
Below is some example code:
<div id="pathways-abc123" data-subject="automap" data-callback="loadCallback"></div> <script> function loadCallback(iframeId, message) { if (message === 'No automapped subject found') { const iframe = document.querySelector(iframeId); iframe.style.display = 'none'; // if jQuery is present you could simply do $(iframeId).hide(); } } </script>
Note that your developer is responsible for the Javascript code that listens for the response of the Pathways callback. If you’ve any questions on this, please get in touch.