I have a long form with many fields. Some fields are hidden and appear only when the user makes some choice. That makes the form longer a moves the page down. After submitting the page stays on the same place but confirmation about submitting apears on the start of the form. User must scroll up to see it.

Any idea to fix it?

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

michelledarling’s picture

I need this by midnight tomorrow for a last-second client request on a website I'm working on. Any ideas????

seppe’s picture

Hi, I've fixed this by using some code from the webform-ajax module in my script.js (the offset is the height of my fixed navigation bar):

    $('.links a:not(.ajax-processed)', context).each(function () {
      $wrapper = $(this).parents('[id^=webform-ajax-wrapper]');
      if ($wrapper.length) {
          $.scrollTo($('.webform-confirmation'), 500, {'offset': -80});
      }
    });

I use the jquery scrollto library here (https://github.com/flesler/jquery.scrollTo), but I think you can easily fix this with default JQuery code (not tested):

    $('.links a:not(.ajax-processed)', context).each(function () {
      $wrapper = $(this).parents('[id^=webform-ajax-wrapper]');
      if ($wrapper.length) {
          var topval = $('.webform-confirmation').offset().top;
          $('html, body').animate({
	        scrollTop: topval
          }, 3000, 'easeInOutQuart');
       }
    });

Anybody made their first commit to this issue’s fork.

anybody’s picture

anybody’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Assigned: » Unassigned

Switching to latest release.

torotil’s picture

Status: Active » Closed (duplicate)

This is an exact duplicate of #2136317: Scroll to top of next or previous page. So closing this issue in favor of the older one.