We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6104
    • 26 Posts
    I am wondering if there is a certain way to use javascript in modx? I am trying to use javascript for a navigation menu. I just have it in a script folder and call it that way. It isn’t working properly in modx, but if I pull the index.html file out into is own folder without modx and run it that way it works fine. Exact same files just not run from modx. Is there something I am missing about the way modx does things? Should I be setting up the javascript a different way?
      • 7231
      • 4,205 Posts
      There are no trick to using js in modx, the paths need to be correct but that is true anywhere. What happens? Does it just not work? If this is the case it may not be finding it. If you do not have one, try adding a <base> tag in your html head?
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don&#39;t know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 15083
        • 697 Posts
        Probably a bad idea to use javascript for navigation if the links are generated in the js - bad from an seo point of view.
        Get firefox, web developers toolbar and firebug. That will help you find out what you are doing wrong. 99% chance your paths are wrong.
          • 6104
          • 26 Posts
          Quote from: jusmeig at Jul 28, 2008, 08:50 AM

          Probably a bad idea to use javascript for navigation if the links are generated in the js - bad from an seo point of view.
          Get firefox, web developers toolbar and firebug. That will help you find out what you are doing wrong. 99% chance your paths are wrong.

          It doesn’t generate the navigation. It is just a scroll effect. The part that isn’t working is in the javascript it is suppose to implement a <div class="back> on the "current" navigation link so that one is highlighted. I will check firebug, I just thought it was wierd that it works fine outside of modx with the same files.

          Thanks
            • 10487 MODX Staff
            • 1,535 Posts
            If the problems persist, a link to the page that is causing the issues would help wink
              Garry Nutting
              Senior Developer
              MODX, LLC

              Email: [email protected]
              Twitter: @garryn
              Web: modx.com
              • 11206
              • 73 Posts
              when you say it doesn’t work - is this occuring when you are LOGGED into the manager, and viewing the page also? I have noticed in the past that sometimes if I am logged into the manager and viewing a site (using the same browser) it can cause problems with some Javascript...
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                That’s because the QuickEdit javascript libraries can cause conflicts with the libraries you’re using. You can disable QuickEdit by going to Resources, Manage Resources, the Plugin tab, click on QuickEdit, and check the Disable plugin box, then save it.
                  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
                  • 6104
                  • 26 Posts
                  Quote from: garryn at Jul 28, 2008, 05:49 PM

                  If the problems persist, a link to the page that is causing the issues would help wink
                  I have this locally on my laptop. I will get it moved to my server soon to show you what I am talking about, but until then here is some more detail:

                  I am trying to use the jquery navigation effect called lava lamp more on it here --> http://www.gmarwaha.com/blog/?p=7#

                  Here is the template and css that I am using for testing.

                  template --> http://paste.mycodenow.com/view/d3fc5ce9
                  css --> http://paste.mycodenow.com/view/e19432ca

                  and the javascript

                  jquery.easing --> http://paste.mycodenow.com/view/6ea639d3
                  jquery.lavalamp --> http://paste.mycodenow.com/view/765571d3
                  jquery.min --> http://paste.mycodenow.com/view/32db5e9d

                  The effect works fine. The problem I am having is the current (active) page isn’t working like it should (staying highlighted). Meaning that when I click on about us it isn’t staying highlighted on about us like it is suppose to. But if I use that html, css, and javascript by itself outside of modx it works fine. Quickedit isn’t the problem either. I have also tried this in the current modx stable and the revolution. Same result in both.
                    • 11206
                    • 73 Posts
                    can you cut and paste the source that is on your laptop (the one not working)? so I can have a look at it, save you having to upload the site.
                      • 6104
                      • 26 Posts
                      Quote from: ganeshXL at Jul 30, 2008, 10:36 AM

                      I just downloaded the sample files, and replaced all href="#" with actual links. Also removed the click function:

                      //click: function(event, menuItem) {
                      // return false;
                      //}

                      But the menus don’t stay on the current page, they always go back to "Home"...
                      Yes this is exactly my problem.

                      Quote from: grahoom at Jul 30, 2008, 10:15 AM

                      can you cut and paste the source that is on your laptop (the one not working)? so I can have a look at it, save you having to upload the site.
                      I am at work right now, but I will when I get home.

                      Thanks