Form controls javascript and messages
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2013 05:56 AM
Hi,
We are developping a lot of form controls is there a way to include javascript and css only when the control are present in the form idem for i18n javascript keys ?
Today we are using
Which is include in all forms. I have try using :
in my controls
But it doesn't work when the form appear under popup mode throwing
TypeError: SpelEditor is not a constructor
SpelEditor is define under spel-editor.js
Regards
Matthieu
We are developping a lot of form controls is there a way to include javascript and css only when the control are present in the form idem for i18n javascript keys ?
Today we are using
<config> <forms> <dependencies> <css src="/modules/custom-autocomplete/autocomplete-ext.css" /> <!– Spel editor –> <css src="/modules/spel-editor/spel-editor.css" /> <css src="/modules/spel-editor/shThemeDefault.css" /> <js src="/yui/editor/editor.js"/> <js src="/modules/spel-editor/spel-editor.js" /> <js src="/modules/spel-editor/shCore.js" /> <js src="/modules/spel-editor/shBrushJScript.js" /> <!– Decision tree –> <css src="/components/form/controls/decision-tree.css" /> <js src="/components/form/controls/decision-tree.js" /> … </dependencies> </forms> </config>
Which is include in all forms. I have try using :
<@markup id="css" > <@link rel="stylesheet" type="text/css" href="${url.context}/res/modules/spel-editor/spel-editor.css" group="form" /> <@link rel="stylesheet" type="text/css" href="${url.context}/res/modules/spel-editor/shThemeDefault.css" group="form" /></@><@markup id="js"> <@script type="text/javascript" src="${url.context}/res/yui/editor/editor.js" group="form" /> <@script type="text/javascript" src="${url.context}/res/modules/spel-editor/spel-editor.js" group="form" /> <@script type="text/javascript" src="${url.context}/res/modules/spel-editor/shCore.js" group="form" /> <@script type="text/javascript" src="${url.context}/res/modules/spel-editor/shBrushJScript.js" group="form" /></@>
in my controls
But it doesn't work when the form appear under popup mode throwing
TypeError: SpelEditor is not a constructor
SpelEditor is define under spel-editor.js
Regards
Matthieu
Labels:
- Labels:
-
Archive
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2013 09:08 AM
Unfortunately as far as I know the answer is no you can't do that. I have looked into it a bit myself so let me give you my reason for thinking so. The way Alfresco includes dynamic forms (like the popup controls) is to dynamically include the form when requested (which is exactly what you want). When you do this script tags are not automatically executed so to ensure the scripts get executed Alfresco strips the script tags out of the generated HTML and executes the scripts. Unfortunately this means that any objects or classes created in those scripts won't be available in the main context.
I wish I could remember where I found the code that does the stripping. It was probably somewhere in alfresco.js but it could have been in form.js or form-runtime.js as well.
Hope this helps answer your question.
I wish I could remember where I found the code that does the stripping. It was probably somewhere in alfresco.js but it could have been in form.js or form-runtime.js as well.
Hope this helps answer your question.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2013 05:57 AM
Thanks,
It answers my question, alfresco should consider refactoring it to make a bit more modular. Anyway if I want to achieved it I should remove the stripping codes or leave all the controls js's included in all my pages.
Regards
It answers my question, alfresco should consider refactoring it to make a bit more modular. Anyway if I want to achieved it I should remove the stripping codes or leave all the controls js's included in all my pages.
Regards
