Skip to main content
Question

Document Preview Events

  • May 22, 2025
  • 5 replies
  • 13 views

Forum|alt.badge.img

I am having trouble finding an exposed event in the Document Preview that would cue my code that the document has been entirely rendered - i.e., all the pages or at least the first page has rendered to the DOM so further work can be done in the DOM.  The 'load' event seems to fire quite early - sometime after the viewer container is rendered but before the contained document is rendered.  The 'pagefocus' event seems to work as expected, except on the first page.  When a document renders, it always focuses in on whatever page was previously viewed, but 'pagefocus' doesn't catch this event.  The 'pagerendered' event doesn't seem to get kicked off at all.  So I actually need to write a nasty poll to wait for the document to be loaded in the previewer?  Currently, if I use the 'load' event, my code doesn't find any DOM elements for the document and does nothing.

5 replies

Forum|alt.badge.img

Hey - thanks for the report. We had a documentation error; the event you're looking for is `pagerender` not `pagerendered`. I've updated the documentation to reflect this fix.

 

Here's an example of the event in action: https://codepen.io/box-platform/pen/owVMVy


Forum|alt.badge.img

I got an email notification that the 'pagerender' event didn't work for you, but I don't see that post anymore. Just wanted to check that it ended up working out!


Forum|alt.badge.img

Yup, I removed the subsequent post, because the 'pagerender' event did eventually work.  There must have been a cached Javascript issue.  Thanks!


Forum|alt.badge.img

I just thought I'd put in a quick reminder that those docs are still incorrect -- at least, this one is: 

 

  https://developer.box.com/docs/file-types-events

 

I'm glad I found this on the forum! 


Forum|alt.badge.img

 Thanks for the heads up! *Now* it should be good 🙂 Double checked it this time! You're a rockstar!

 

https://developer.box.com/docs/file-types-events