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

    I’m looking for a push in the right direction for how to go about getting weblinks to fire a javascript function instead of calling a URL. The idea is to easily make my wayfinder set up compatible with my fancy AJAX page.

    Is this at all the right way to go about it? Is there somewhere I can modify the ’makeURL’ function in MODx so the weblink field will understand something like:

    ’javascript:void(0)" onclick"ajax_call();"’ ?

    Cheers,

    Greg.
    • If you are using a recent version of Wayfinder, it should do that all by itself. Basically, for a weblink, it uses the content of the document, and if it’s not a number, makes the link directly from the content. Have you tried just putting the javascript in the weblink?
        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
        • 15426
        • 12 Posts
        Heh. Absolutely, it works. Silly me... I was so focussed in on trying to use onclick that I forgot to try calling the javascript from the href.

        If anyone else gets dense like me just put ’javascript:function(x);’ into you’re weblink addy.

        Thanks!

        Greg.

        P.S. Any ideas as to how another event might be called such as onclick or mouseover? Just out of curiosity. Double quotes get cancelled out of the form field.