3 Replies Latest reply on Apr 23, 2018 2:54 PM by brittneywilson

    Jive 7 theme where to put custom js in

    Powell Intermediate

      I need to add some custom script to my theme.

      1.) is /soy/template/javascript.soy the new place?

      2.) where in this file can I put script to be executed on everypage

      like something simple like

      <script type="text/javascript">

      $j(document).ready(function() {

      alert('hey');

      });

      </script>

       

      Thanks!

      Powell

        • Re: Jive 7 theme where to put custom js in
          mcollinge Expert

          If it needs to be executed everywhere, I'd personally put it in a plugin (we have one for Jive 6 called JavaScript-Libraries) and say this in your plugin.xml file;

           

          <javascript src="/plugins/javascript-libraries/resources/script/my-global-stuff.js" />

           

          That'll make the JS file load on each and every page. The only limitation here is that it's pure JS and you'll not be able to do any FTL/Soy based processing (like bringing in a system property, i18n or things like that).

          • Re: Jive 7 theme where to put custom js in
            mbrybag Novice

            We are also on Jive 7 and have custom javascript running on document.ready for every page as well. We place all our JS code into a file stored in the scripts folder in our theme.

             

            First create the js file and save it to your theme. We use lots of jquery so our theme.js file looks like this:

             

            $j(function($){

              //script to execute

              $('.selector').dosomething();

            .....

            });

             

            Then add the script tag to include your custom js file in /soy/template/javascript.soy

            <script src="{themeUrl('/scripts/theme.js')}"></script>

             

            That should be it.

            • Re: Jive 7 theme where to put custom js in
              brittneywilson Novice

              I have a script that was built by a previous developer. It's referencing this file: "/api/core/v3/attachments/file/5891/data"

               

              Where would that be stored/how can I get to it in the admin console?