0

I am loading some additional Javascript in the template of the newAction() of my controller:

Templates/Controller/New.html

<f:section name="FooterAssets">
    jQuery(document).ready(function ($) {
        // do something
    });
</f:section>

This works perfectly fine, but as soon as an error occurs when I save the record, the FooterAssets assets are not loaded anymore. So somehow the createAction() does not load/add the FooterAssets.

Is there a way to load the FooterAssets if an error occurs when saving a record?

And a more general question:

Are the HeaderAssets and FooterAssets the recomended way to include specific Javascript or CSS for an controller action?

chris
  • 2,109
  • 2
  • 23
  • 33
  • May this will help you https://stackoverflow.com/questions/45440189/typo3-how-could-i-add-css-and-js-files-via-controller-initialize-action-and-pag – gautamsinh mori Apr 04 '19 at 03:53
  • @gautamsinhmori I think, I am doing exactly, what they do, or am I missing something? But my questions is about loading the `FooterAssets` in the `createAction()` which has no template itself. – chris Apr 04 '19 at 13:24
  • How do you want to load JavaScript/jQuery without any template? What do you want to achieve with JS in your `createAction()` ? – Naderio Apr 14 '19 at 14:26
  • @gautamsinhmori My problem occurs, when I create a new record, but the validation fails. In this case the `FooterAssets` of the template `New.html` are not loaded. So initially loading the `NewAction()` works perfectly fine, but submitting a form which does not validate, will not load the `FooterAssets` anymore. – chris Apr 14 '19 at 20:26

0 Answers0