Just leaving this here incase anybody else wants to:
- refresh the manager so a tv value that was set programmatically will be displayed on refresh
- only refresh the manager page if a tv checkbox is set to 1 (checked)
case 'OnDocFormPrerender':
$modx->regClientStartupHTMLBlock('
<script type="text/javascript">
Ext.override(MODx.panel.Resource, {
originalSuccess: MODx.panel.Resource.prototype.success
,success: function(o) {
this.originalSuccess(o);
var tv = Ext.get("tv62-0").dom.checked;
if (tv && tv == "1") {
var url = location.href, i = url.indexOf("?") + 3;
MODx.loadPage(url.substr(i));
}
}
});
</script>
');
break;
In my particular scenario, I created a checkbox tv and moved it into "modx-resource-main-right" using form customisation.
Next, I needed to find out the ID of my TV by viewing the source of the manager. It gave me an ID of "tv62-0". Do not use ExtJS generated ID's as these change over time (you might think everything is working, only to find out an hour later it has stopped working).
The problem with my ID is that the value was always set to "1", even if the checkbox was checked or not. The fields that did change the values dynamically had ExtJs generated IDs. So by adding "dom.checked" rather than "dom.value" we have something to hook on to (unless you find another way of searching for an element by name rather than ID!)
var tv = Ext.get("tv62-0").dom.checked;
Good luck!
[ed. note: jonleverrier last edited this post 7 years ago.]