Skip to content

Using Confirm and scrollTop in action causes page to scroll up and then back down #468

Closed
@dcdalton

Description

@dcdalton

jquery-confirm version:
v3.3.0

I'm submitting a ... (check one with "x")
[ ] bug report
[ ] feature request
[x] support request

Current behavior:
Using the jQuery confirm to tell user there are issues within the submitted form, in the action on the button I have a scrollTop. When the button is clicked the page scrolls to the top and then back down to the bottom.

Expected behavior:
Expect page to scroll top and stay there, here is my code:

$.alert({
	boxWidth: '50%',
	useBootstrap: false,
	title: '<p>Questionnaire Errors Found</p>',
	titleClass: 'alert_title',
	content: "<p class='alert_body'>Errors were found in the submitted questionaire and are highlighted in red</p><p class='alert_body'>Please review and correct the missing information</p>",
	buttons:	{
		okay:	{
			text: 'Okay',
			btnClass: 'alert_button',
			action: function()	{
				$('html').stop().animate({
					scrollTop: $('#voters_guide_form').offset().top
					}, 500);
							
				}
			}
		}
	});

I should also note without using jQuery-confirm the behavior is correct. I have also played with using different element ids in the scrollTop and even added the .stop() before the animate call. Nothing changes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions