How to include a new client side javascript dependency into form.get.html.ftl
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2016 02:38 PM
Hello.
I'm trying to include a new dependency for form.get.html.ftl using a extension module.
My custom ftl file contains the following code:
But it seems my code is ignored.
The extension module definition is:
What I ended up doing is including the dependency using share-config:
I'm trying to include a new dependency for form.get.html.ftl using a extension module.
My custom ftl file contains the following code:
<@markup id="group-member-form-control-dependencies" target="js" action="after" scope="global"> <@script src="${url.context}/res/components/object-finder/group-member.js" group="form"/></@markup>
But it seems my code is ignored.
The extension module definition is:
<extension> <modules> <module> <id>Custom group member form control dependencies</id> <auto-deploy>true</auto-deploy> <customizations> <customization> <targetPackageRoot>org.alfresco.components.form</targetPackageRoot> <sourcePackageRoot>org.orderofthebee.components.form</sourcePackageRoot> </customization> </customizations> </module> </modules></extension>
What I ended up doing is including the dependency using share-config:
<config> <forms> <dependencies> <js src="/components/object-finder/group-member.js" /> </dependencies> </forms> </config>
Labels:
- Labels:
-
Archive
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2016 05:00 AM
Going the configuration way IS the proper way to include custom form dependencies. Depending on the use case, the the form.get.html.ftl may not be used to initialize a form context, e.g. some components include the form.js.ftl and form.css.ftl to get all the form dependencies. Customizing form.get.html.ftl will miss those use cases, but configuration will work fine.
The scope attribute for a @markup is not relevant / defined at all. Also a @script inside a @markup may behave differently than what you would expect, e.g. if the @markup has an action of "before" the script you include will still be loaded after any scripts from the element you targeted. Additionally, it is impossible to use the action of "replace" to remove any @script dependency, since those are always decoupled from the @markup that surrounds them (deferred template model).
The scope attribute for a @markup is not relevant / defined at all. Also a @script inside a @markup may behave differently than what you would expect, e.g. if the @markup has an action of "before" the script you include will still be loaded after any scripts from the element you targeted. Additionally, it is impossible to use the action of "replace" to remove any @script dependency, since those are always decoupled from the @markup that surrounds them (deferred template model).
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2016 09:08 AM
Thank you Axel.
