We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11243
    • 27 Posts
    Hi, I’ve got my eForm working within a jQuery Dialog popup that is opened from a link on the page. The eForm works well but the problem I am having is that I need the jQuery Dialog to open automatically upon returning to the page once the form submission has taken place in order for the user to be able to see the feedback or validation errors. At the moment you have to click the popup link again to be able to see this information.

    If I can determine that the page is returning from a submission then I should be able to set the autoOpen method of the Dialog object to true instead of false? Does anybody have an idea of how I can detect this or have any other ideas on how I can achieve this?
      • 23491 ☆ A M B ☆
      • 1,056 Posts
      Quote from: graviteski at Jul 28, 2009, 10:31 AM

      Hi, I’ve got my eForm working within a jQuery Dialog popup that is opened from a link on the page. The eForm works well but the problem I am having is that I need the jQuery Dialog to open automatically upon returning to the page once the form submission has taken place in order for the user to be able to see the feedback or validation errors. At the moment you have to click the popup link again to be able to see this information.

      If I can determine that the page is returning from a submission then I should be able to set the autoOpen method of the Dialog object to true instead of false? Does anybody have an idea of how I can detect this or have any other ideas on how I can achieve this?

      I have done this easily in the past with MooTools by checking the DOM for existence of a particular element/value, usually something returned in your eFrom &thankyou parameter. You can also wrap your "[+validationmessage+]" placeholder in a container, and check for the presence of errors on form submit to conditionally (but automatically) invoke your modal form. The same can be accomplished with jQuery, native JavaScript, or other JS frameworks...
        Mike Reid - www.pixelchutes.com
        MODx Ambassador / Contributor
        [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
        ________________________________
        Where every pixel matters.
        • 11243
        • 27 Posts
        Thanks for the quick feedback PixelChutes and good to know that it can be done. I shall persevere along these lines today and report back on my success (or lack of it!) Cheers!
          • 11243
          • 27 Posts
          Success!

          Here’s what I ended up doing - an interesting mix of technologies, MODx, PHP, javascript and jQuery!

          Unfortunately you can’t get at POSTed values via javascript, but you can through PHP, so I created a new SubmitCheck snippet with the following code to check for the presence of the formid value, which is present in every eForm submission:
          <?php
          $hasPosted = "false";
          if (isset($_POST['formid']) && ($_POST['formid']!='') ) {
          $hasPosted = "true";
          }
          return $hasPosted;
          ?>

          I then pulled this info into a javascript variable in my page header so that once the page has loaded and the jQuery dialog initialised it then calls the jquery method to open the dialog if required:
          <script type="text/javascript">
          var isPosted;
          isPosted = [!SubmitCheck!];
           $(document).ready(function(){
              $("#enquiry").dialog({
                bgiframe: true, autoOpen: false ,height: 600, width: 780, modal: true
              });
             if (isPosted) $("#enquiry").dialog('open');
          </script>
          


          Thanks again to PixelChutes for making me think about using javascript to control the display of the dialog. Hope this helps somebody else.
          Cheers!
            • 36926
            • 701 Posts

            <?php
            $hasPosted = "false";
            if (isset($_POST[’formid’]) && ($_POST[’formid’]!=’’) ) {
            $hasPosted = "true";
            }
            return $hasPosted;
            ?>

            Any reason for this snippet code not to work in Revo with formIt. I’ve changed the snippet call to the correct Revo syntax. Every thing works about from the dialog opening again to display the message.
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              In my implementation of something similar, I used the various tpls to provide a div with an id attribute for everything, and had the javascript checking for the existence and content of these divs. Using a blank resource with an eForm call as the AJAX processor took care of getting the form displayed and posted behind the scenes as it were. I keep meaning to implement this on my site’s slide-down contact form, but haven’t gotten around to it yet. It was actually pretty easy; I imagine formit would behave in much the same way.
                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
                • 36926
                • 701 Posts
                Quote from: sottwell at Nov 12, 2010, 12:09 PM

                In my implementation of something similar, I used the various tpls to provide a div with an id attribute for everything, and had the javascript checking for the existence and content of these divs. Using a blank resource with an eForm call as the AJAX processor took care of getting the form displayed and posted behind the scenes as it were. I keep meaning to implement this on my site’s slide-down contact form, but haven’t gotten around to it yet. It was actually pretty easy; I imagine formit would behave in much the same way.
                Thanks Susan for the suggestion. I actually added a hidden input field and check for that with:
                <?php
                $hasPosted = "false";
                if ($_REQUEST['submitted']==1){
                $hasPosted = "true";
                } 
                return $hasPosted;