We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37317
    • 77 Posts
    Hi,

    Is it possible to call a snippet from a JS file.

    For example:
    $('.mainarea').append('[[!Gallery? &album=`Ariana` &autoStart=`0` &plugin=`galleriffic` &numThumbs=`100` &prevLinkText=`<`  &nextLinkText=`>`  &enableHistory=`1` &imageWidth=`700` &imageHeight=`600` &navigationWidth=`0px` &renderNavControls=`1` &captionContainerSel=`0` &renderSSControls=`0` &enableTopPager=`1` &enableBottomPager=`0` &defaultTransitionDuration=`700` &delay=`1000` ]]');


    If I do this, it just prints out the above into the div, but doesn't run it.

    I need to pretty much load the snipprt from the JS file in a specific div.

    Another way I tried was creating a resource page, adding the snippet call without any headers/template using jquery load into the div. It grabs the html, but since I have no headers, it wont create the plugins i need (js & css files).
    $('.mainarea').load("portfolio2.html?galAlbum="+hasID); 


    In another words, loading a snippet from a js file using jquer ajax/load.

    help?

    10x [ed. note: meytal1 last edited this post 14 years, 9 months ago.]
      • 3749
      • 24,544 Posts
      You can probably do it with Ajax, but it's usually easier to do it the other way around. Just make a regular MODX page with the snippet tag and use $modx->regClientCss() and $modx->regClientStartupScript() to inject the CSS and JS, and $modx->runSnippet() (if necessary) to run any other snippets.


      ---------------------------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
      MODx info for everyone: http://bobsguides.com/MODx.html
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 37317
        • 77 Posts
        I decided to put an iframe instead of a div.
        so i just change the src of the iframe and load the content within.
        this way, i wont have to deal with reloading JS & CSS files.
        have a look.
        www.shaysamia.com/portfolionew.html
        10x