We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9995
    • 1,613 Posts
    Is there a (javascript) method where I can change a chunk loaded into the template or the template itself by a frontend link?

    I have an one page website and there needs to be two links.
    One link loads chunk "1" and the other link loads chunk "2".
    The URL i like to keep unchanged.
      Evolution user, I like the back-end speed and simplicity smiley
      • 9995
      • 1,613 Posts
        Evolution user, I like the back-end speed and simplicity smiley
        • 30023
        • 172 Posts
        Either:

        1. Use ajax to load the chunk. The chunk can be via a MODx 'page' that only consists of that chunk. If you like jQuery use jQuery's load(). If you want to use normal non-library based javascript then you probably don't need anyone else to tell you what to do.

        2. Include both chunks on your page but hide one and show it (and hide the other) with javascript manipulating the CSS display property.

        (1) Is better for very large chunks. (2) is better for smaller chunks and will feel more responsive to the user.

        -- Tim.


          • 9995
          • 1,613 Posts
          Not sure about SEO, guess sitemap is needed when using ajax and top:-999px; for jQ.





            Evolution user, I like the back-end speed and simplicity smiley