I'm trying to port a portlet that uses jQuery to prepopulate some date fields in the edit mode of a portlet. jQuery's document.ready isn't fired once view mode has been seen once as it seems like the mode switch is happening without a full page load, probably using some fancy ajax or whatnot. Is there any way to force mode switches to do full page loads? If not, can I somehow fire a javascript method after the mode change render completes?

No, I still haven't figured out a way to fire a javascript function/callback after the mode change finishes. I am already using the GateIn JS AMD module configuration for my script. The problem seems to be twofold:

If I run something inside a jQuery $(document).ready declaration in my AMD script, it won't fire again after the mode changes since it isn't a full page reload, just an AJAX call that replaces content.

If I try to use one of the approaches you suggested above, I can't tell GateIn that I want to use the inbuilt jQuery version because you can only define a portlet as having a module OR a script, not both, and 1 and only 1 of whichever you choose. The recipe in the documentation for making jQuery globally available requires the use of a script in the portlet declaration in gatein-resources.xml. I need my script to be a module because it has dependencies on other AMD modules. I guess I could add a contentless dummy portlet that exposes jQuery in the window and add that to the page, but that seems like a terrible hack to me.

The only examples I can find for the use of JavascriptManager are inside groovy templates, which I'm not using. They access some magic object _ctx to get the JavascriptManager instance and I don't know what that object is or how to access it from my portlet class. Or do I just construct a new one? Are there secret docs on how to use JavascriptManager somewhere?