Copy link to clipboard
Copied
Hi,
I am considerig a rewrite of a scriptUI panel as a html panel.
The code currently performs some jsx script in order to populate some fieds of the UI with values from the current document.
With separate client and host scripts starting up, the client might call the host script before it is loaded.
Is there anything the client can do to wait for the host script to load? I have not seen any mention of the problem in the docs
Copy link to clipboard
Copied
Without going into implementation details, two issues speak to your question:
User clicks button -> execute jsx specifying callback function -> jsx gathers and returns data from document -> callback function receives returned data and updates panel UI.
The CEP panel can be written in ES6 javascript and use any function available to Chrome version 74.
Hope that broad overview is helpful.
Copy link to clipboard
Copied
Hi,
many thanks for your response. I am aware that, once the user has switched habits from closing/reopening the panel to just leaving it in place, everything will be fine.
In fact, the panel version can get notified about changing the active document and reload data.
The question remains open: what happens if the user opens the panel for the first time in a session - or, in other words, can I avoid an extra button that was not necessary with the ScriptUI version
Copy link to clipboard
Copied
Well, you can put your update code in all the entry points, eg. startup (eg. in the html file so it runs as soon loaded) or, as you mention, in response to a document load event. Actually I think the "documentAfterActivate" event might be called in either case, so try putting your code there first. Other than that, I think you'd have to rely on whatever events CSEvent gives you.
If that doesn't cover your requirement, it would help to tell us your ideal trigger for updating your panel. At worst case, you might need a "refresh" button or something like that, which could be hidden if your update code has already run.
Edit: I guess there's nothing stopping your CEP code from sort-of 'polling' the document every so often, but I'm not sure if that'd be a good way to go.