I'm trying to share javascript code between a plugin and the field descriptors for custom fields.
I created a web resource javascript plugin that looks like the following:
AJS.$(document).ready(function() {
function CALLME() {
alert('CALLME Called');
}
console.log("plugin ready function");
CALLME();
});
In a field descriptor for a custom field I have the following code:
<script type="text/javascript">
AJS.$(document).ready(function() {
console.log("field ready function");
CALLME();
});</script>
The plugin is loaded before the field descriptor via the console messages. But I'm getting the error in the field descriptor that 'CALLME' is undefined.
Is what I'm trying to do possible? Share javascript code across field descriptors and a plugin?
I could put the code in the 'Summary' field configuration for every Field Configuration but I have many and don't want to duplicate code.
Thanks.