When reloading an extension page (new menu item), the page reloads with a blank.
I have to go to the menu and click on my extension to see the actual page.
Currently my extension page is constructed by the client side js - which probably is the reason the extension page is blank on reload.
Option 1/ What do I have to do for the reloaded page to update (be refreshed as it gets built) without requiring the user to click on the menu?
Or, option 2/ is there a way to build the whole extension page content on the server side? Is there any example code I could learn from?
Subsidiary question to 2/: how do I push an updated page to the client?
I have not yet changed my code to avail of the load function, but I corrected a bug in my show function, where I expected the build (in the constructor) to have completed when it had not (lots of futures). So I fixed my bug by encapsulating my show code within a then clause.
But to properly avail of the new load function I’d have to adapt this example as I do quite a bit of DOM manipulation (currently in the constructor) - constructing menus based on webthings & other configuration data.
I tried to use the load function, but it seems that the base object (this.view for instance) is not ready, whereas it was ready for use in the constructor. Not sure yet what I am doing incorrectly.
Assumption: I presume load() is called once only (at page load/refresh), then never again until the browsing session ends (or next reload). And show() gets called every time the menu entry is clicked.
Q1/ With that in mind, what is the rationale for putting this.view.innerHTML = this.content; in show()? Why not put this in the load() function?
Suggestion: Incidentally, why isn’t there a hide() function? (one may need to stop or suspend various processing when the view is not shown).
Q2/ I was hoping for an example where the page building might be done on the server side. Or is it just a matter of replacing the fetch for content.html to fetch from the API Handler?
Assumption: I presume load() is called once only (at page load/refresh), then never again until the browsing session ends (or next reload). And show() gets called every time the menu entry is clicked.
That’s accurate.
Q1/ With that in mind, what is the rationale for putting this.view.innerHTML = this.content; in show() ? Why not put this in the load() function?
No reason. It could’ve been done either way.
Suggestion: Incidentally, why isn’t there a hide() function? (one may need to stop or suspend various processing when the view is not shown).
That would’ve required a semi-large re-architecting of our UI when we added extensions. That’s the only real reason.
Q2/ I was hoping for an example where the page building might be done on the server side. Or is it just a matter of replacing the fetch for content.html to fetch from the API Handler?
Yes, exactly. Just fetch it from your API handler.
Assumption: I presume load() is called once only (at page load/refresh), then never again until the browsing session ends (or next reload). And show() gets called every time the menu entry is clicked.
That’s accurate.
Seems not.
I just ran a test and load() is called every time i click on the extension menu item.
So really, one should build the page in the constructor, not in load().
Suggestion: Incidentally, why isn’t there a hide() function? (one may need to stop or suspend various processing when the view is not shown).
That would’ve required a semi-large re-architecting of our UI when we added extensions. That’s the only real reason.
I have just discovered that actually the hide() function does exist in the client side extension class. So we must have been at cross purposes. Things seem to have some sound logic after all.