Sha256: fd31a4367b46559a162853702ad29bae8971e23dad1f2786daeef6f0aea844b8
Contents?: true
Size: 1.8 KB
Versions: 6
Compression:
Stored size: 1.8 KB
Contents
= Javascript You can add Javascript code by multiple ways in Decidim: == Asset pipeline Just add it to `app/assets/javascripts/application.js`. For example to create a new alert just add: [source,javascript] ---- $(function(){ alert('foobar'); }); ---- More information in https://guides.rubyonrails.org/asset_pipeline.html[Rails Asset Pipeline documentation]. == Head extra file There's an special partial file for adding inline content in every public page. You just need to create a file called `app/views/layouts/decidim/_head_extra.html.erb`: [source,javascript] ---- <script type="text/javascript"> $(function(){ alert('foobar'); }); </script> ---- == Custom HTML Header snippets If you need changes on a multitenant installation, you can do so by enabling a configuration in your `config/initializers/decidim.rb` file. Please do notice that this has security implications: [source,ruby] ---- # Custom HTML Header snippets # # The most common use is to integrate third-party services that require some # extra JavaScript or CSS. Also, you can use it to add extra meta tags to the # HTML. Note that this will only be rendered in public pages, not in the admin # section. # # Before enabling this you should ensure that any tracking that might be done # is in accordance with the rules and regulations that apply to your # environment and usage scenarios. This feature also comes with the risk # that an organization's administrator injects malicious scripts to spy on or # take over user accounts. # config.enable_html_header_snippets = true ---- Then you'll have a new textarea field called "Header snippets" in Administration -> Configuration -> Appearance (URL `/admin/organization/appearance/edit`): image::header-snippet.png[Header snippet] Notice that you can resize this textarea.
Version data entries
6 entries across 6 versions & 1 rubygems