We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39515
    • 5 Posts
    MODX Revolution 2.2.0-pl2 (traditional)
    formit-2.0.3-pl

    I have a working formit form inside a div that calls a snippet to save the form data (a new story) to the database.
    [[!FormIt?
    &hooks=`addstyDB`
    &validate=`nospam:blank,stytitle:required:stripTags`
    ]]
    On success of the form submit and addition to the database I would like to to run a jquery command to reload another div on the same page that will refresh a list of all the users stories including the newly added. The only bit I'm stuck on is being able to get a formit hook to fire the jquery.

    Any suggestions?

    Ta very muchly smiley
      • 32316
      • 387 Posts
      formit hook is php - running on the server
      jquery - running in the browser
      php code on the server cannot not 'call' js in the browser

      a possible solution would be for the the formit hook to add the jquery code to the page as needed - the jquery code would would run once the page was loaded.
      But why do you need the jquery? It seems to me that if you are running a snippet (php to process the from submission) you might as well do the content refresh with php code at the same time rather than create a page and then run some js code and then load (with presumably ajax) the refreshed content (which is going to involve php on the server side).
        • 39515
        • 5 Posts
        Hi Whistlemaker, thanks for the reply.

        The page doesn't reload, just the contents of the various divs, hence the need for jquery. I gave up on the using formit for the reasons you said and figured out another way.

        Thanks any way smiley