Come for answers. Stay for best practices. All we’re missing is you.
I am trying to use methods from the JS API within the sample code for the viewer toolbar plugin, specifically this function here: https://github.com/ibm-ecm/ibm-content-navigator-samples/blob/master/ViewerToolbarPlugin/src/com/ibm/ecm/extension/viewerToolbar/WebContent/ViewerToolbarPlugin.js#L14-L19
However, it is not clear to me how to invoke/use this API within the sample.
Any guidance is greatly appreciated!
for clarity, this is the JS API I am attempting to use: https://www.ibm.com/docs/en/daeja-viewone/5.0.x?topic=javascript-api-reference
You should be able to call the API methods using the 'this.viewer' object. Please let me know if this doesn't work.
Regards,
Andy
Andy,
This does not work and I get an undefined error. When logging `this` in this function, it appears to be the window object, and I do not see `viewer` in there.
I did some other testing and did have luck accessing the `this.viewer` object in this function of the sample: https://github.com/ibm-ecm/ibm-content-navigator-samples/blob/master/ViewerToolbarPlugin/src/com/ibm/ecm/extension/viewerToolbar/WebContent/ViewerToolbarPlugin.js#L37-L52 and I am able to access the desired methods.
Thanks!
You're right. 'this.viewer' can only be accessed when the event handled is attached as the custom button 2 in the sample plugin.