4 Replies Latest reply on Jan 26, 2016 10:29 AM by mrkustka

    Uncaught ReferenceError: $ is not defined

    mrkustka

      I'm using a HTML tile to create an accordian menu. My code works great outside the JIVE environment. However, when placed in the HTML tile I receive "Uncaught ReferenceError: $ is not defined". Below is a code snippet:

       

      <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

      <script>

      $(document).ready(function() {

          //toggle the component with class accordion_body

         $(".accordion_head").click(function () {

              if ($('.accordion_body').is(':visible')) {

                  $(".accordion_body").slideUp(300);

                  $(".plusminus").text('+');

              }

              if ($(this).next(".accordion_body").is(':visible')) {

                  $(this).next(".accordion_body").slideUp(300);

                  $(this).children(".plusminus").text('+');

              } else {

                  $(this).next(".accordion_body").slideDown(300);

                  $(this).children(".plusminus").text('-');

              }

        $('.accordion_head.active').removeClass('active');

              $(this).addClass('active');

          });

      });

      </script>

       

      Anyone know how to resolve this issue?

       

      Thanks.

          • Re: Uncaught ReferenceError: $ is not defined
            mrkustka

            Thanks for your suggestion. HTTPS added and no change. See screen shot. Error still exists and accordions don't function.

              • Re: Uncaught ReferenceError: $ is not defined
                pawans

                I had this issue too. Somehow the code added in jive's HTML tile could not detect jquery.

                  • Re: Uncaught ReferenceError: $ is not defined
                    mrkustka

                    I was able to resolve this by the following code. Thanks for you help and responses.

                     

                    <script>

                    (function() {

                          function getScript(url,success){

                            var script=document.createElement('script');

                            script.src=url;

                            var head=document.getElementsByTagName('head')[0],

                                done=false;

                            script.onload=script.onreadystatechange = function(){

                              if ( !done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete') ) {

                                done=true;

                                success();

                                script.onload = script.onreadystatechange = null;

                                head.removeChild(script);

                              }

                            };

                            head.appendChild(script);

                          }

                            getScript('https://my.capital.org/resources/scripts/jquery/jquery.js',function(){

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

                        //toggle the component with class accordion_body

                      $j(".accordion_head").click(function () {

                     

                            if ($j('.accordion_body').is(':visible')) {

                                $j(".accordion_body").slideUp(300);

                                $j(".plusminus").text('+');

                            }

                            if ($j(this).next(".accordion_body").is(':visible')) {

                                $j(this).next(".accordion_body").slideUp(300);

                                $j(this).children(".plusminus").text('+');

                            } else {

                                $j(this).next(".accordion_body").slideDown(300);

                                $j(this).children(".plusminus").text('-');

                            }

                      $j('.accordion_head.active').removeClass('active');

                            $j(this).addClass('active');

                        });

                    });

                            });

                        })();

                    </script>

                    1 person found this helpful