We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21893
    • 113 Posts
    Hi Guys,
    I m transfering a finished Design with a bought jquery-solution to a modx-evolution (1.10) Installation.

    Im getting grey hair, since im trying for the whole day now to get a slideshow working.
    I trie

    Im a jquery Dummy, but i guess my problem lies in a script file. Since I can get everthing to work out of modx or if i use the original jquery and flexslide files.

    This is working:
      <script language="JavaScript" src="assets/js/jquery.js" type="text/javascript"></script>
      <script language="JavaScript" src="assets/js/jquery.flexslider.js" type="text/javascript"></script>
    
    <!-- Hook up the FlexSlider -->
    	<script type="text/javascript">
    		$(window).load(function() {
    			$('.flexslider').flexslider();
    		});
    	</script>


    If I used the "official" version
        <script src="js/jquery.js"></script>
        <script src="js/script.js"></script>

    with this script it NOT WORKIN in MODX
    include('js/superfish.js')
    include('js/jquery.hoverIntent.minified.js')
    include('js/jquery.flexslider.js')
    include('js/forms.js');
    include('js/jquery.mobilemenu.js');
    
    //----Include-Function----
    function include(url){ 
      document.write('<script src="'+ url + '" type="text/javascript"></script>'); 
    }
    
    $(function(){
      $('.flexslider').flexslider({
          animation: "fade",
          controlNav: "thumbnails"
        });
    
      
    // .....................


    Is there someone knowing what i can do to use this script?
    Thanks
      Smile, it confuses people!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Are you sure you've included the JQuery library before including the rest of them? What errors are shown in your browser's error console?
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 21893
        • 113 Posts
        Quote from: sottwell at Jul 21, 2013, 08:37 PM
        Are you sure you've included the JQuery library before including the rest of them? What errors are shown in your browser's error console?
        Hi Susan,

        Im sure of the right including. I tried a lot of things, since I didnt understand the probelem (4x checking links,different folders for jscript etc etc.) I came out its working everwhere outside of modx. For example I put the whole stuff in a different folder out of modx but on the same server, no problem. |-O grrrrrr

        No I used the Webdeveloper (mozilla) error-Tool and it shows me an error:
        Zeitstempel: 22.07.2013 09:31:18
        Fehler: TypeError: $(...).flexslider is not a function
        Quelldatei: http://www.xxx/assets/js/script.js
        Zeile: 15


        But my knowledge of jquery or "innersystem" is to poor to understand what to do.

        Thank you
          Smile, it confuses people!
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          That usually means that a required library is missing. Perhaps it is loaded in the wrong place - it has to be loaded before its calling function is called. Usually, I put js libraries at the end of the template, just before the closing body tags, and wrap the calling functions in a document.ready() or window.load() function. That means that the function won't get called until the whole page is loaded, so the libraries will be loaded. According to the FlexSlider docs -
          // Can also be used with $(document).ready()
          $(window).load(function() {
            $('.flexslider').flexslider({
              animation: "slide"
            });
          });

            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            I load the libraries at the end of the body because whenever the browser finds a link to a javascript library, it stops processing the page until the library is downloaded. This can make a page very slow to load. By putting the library includes at the end of the page, the full HTML part of the page is loaded in the browser before the libraries are downloaded.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 21893
              • 113 Posts
              Hi Susan,

              im sorry, again it was a "problem in front of the keypad". I deleted line 15 and it was working. After that i decided to load up all the js-files - even those i thought i dont need :-(
              Well, thats it. WORKING NOW

              Thanks for the advice for scripts, I will use it.
              Can I ask another question here (i still do have errors after a change of server)?
              I make up a new question, if you still have time.

              And again thank you
                Smile, it confuses people!
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                If I can't answer your questions, somebody else will. That's what the "community" is for! Best to check the boards, though, to make sure to ask your new question in a new post in the appropriate board (for example, Wayfinder has its own board).
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org