Policy Automation for B2C Service

Get Involved. Join the Conversation.


    Cy Routh
    Javascript libraries not loading when embedded in div
    Topic posted October 25, 2019 by Cy Routh 
    26 Views, 1 Comment
    Javascript libraries not loading when embedded in div
    Custom javascript is working in debugger and iframe, but does not load in div

    I have a client trying to embed an interview in a div on their site. The interview uses several javascript libraries for an interview extension (a leaflet map control). Everything works in the debugger, on the hub, and when embedded in an iframe. When we try to embed in a div, the libraries are not loaded/accessible. Client wants to pursue div over iframe due to the Safari domain mismatch issue.

    I think this is because the client site is using a module loader (AMD?). The control extension expects the libraries to be loaded into the browser's Global scope, but they're not there. I can see the files listed among the site's source files, but the OPA interview can't use them. Is there a way to define interview extensions that is compatible with javascript module loaders? I can figure out some basic javascript, but this module thing is a bit over my head right now.

    They're investigating some possible workarounds to disable their module loader when invoking the OPA interview, but it would be nice to be able to handle this sort of thing gracefully from within the interview extension.







    • Cy Routh

      Well, I stripped out all of the module-friendly wrappers from my map libraries so that they all get dumped into Global scope in the browser, and I combined all of my custom javascript (external libraries and interview extension) into a single file to avoid any module or asynchronous loading issues. That seems to have gotten us past the loading issues we were having (although it has presumably introduced some maintenance issues for later).

      There were still some issues (only on their server) due to some css from the map libraries being overridden by interviews.css. We were able to get past that by using OraclePolicyAutomationInterview.BatchStartOrResume with disableEnforcedStyling.

      Does anyone have a cleaner and less intrusive way to handle dependencies without a module loader but without having to hack external javascript libraries and while remaining module-friendly? There's got to be a better way.