I have some fields that are being rendered using the <f:all> tag.
Three of those fields need an "onClick" attribute so I can turn on/off some manadatory settings on other fields upon clicking.
I have added the correct javascript function and tried initializing it with an init() function in the body's onload section:
<body onLoad="init()">
...
</body>
The init function looks like this:
function init() {
const exportElement = document.getElementById('export');
const importElement = document.getElementById('import_');
const transitElement = document.getElementById('transit');
exportElement.onclick(this.validate());
importElement.onclick(this.validate());
transitElement.onclick(this.validate());
}
The section in the gsp page looks as followed:
<g:form resource="${this.agreement}" method="POST">
<fieldset class="form">
<f:all bean="agreement" associationValues="${associationValues}"/>
</fieldset>
<fieldset class="buttons">
<g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" />
</fieldset>
</g:form>
My understanding is that the elements are not yet rendered when the onload() function is called since it's called immediately on load. Therefore this idea cannot work, so here's what I'm thinking:
I know it's possible to remove some elements from the f:all scope using the "except" attribute. Can I somehow add the requirements element containing the onclick() attributes manually in a specific order or will I need to completely switch to a manual fields implementation?
Thanks for any pointers.