Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

jquery modal dialog scrolling to bottom

Posted on 2014-03-02
7
Medium Priority
?
3,260 Views
Last Modified: 2014-03-09
Hi,

I have this page:
https://secure.myultratrust.com/diy/login/create_username.php

If one clicks on the "Privacy Policy" and "Terms of Use" links at the bottom the modal dialog will scroll to the bottom. It's strange because if you first click on the "Privacy Policy" the modal dialog is at the top. But then when you click on "Terms of Use" the modal dialog scrolls to the bottom.

However, if you refresh and the first click "Terms of Use" the modal dialog opens at the top but then if you click on "Privacy Policy" the modal dialog scrolls to the bottom.

It just depends on what link you click on first.

Here is the code in the jquery plugin:

termsOfUseModal : function() {
            $( "#dialog:ui-dialog" ).dialog( "destroy" );

            $( "#terms_of_use" ).dialog({
                modal: true,
                width: 800,
                title: "Terms of Use: MyUltratrust.com",
                position: 'top',
                buttons: {
                    Ok: function() {
                        $( this ).dialog( "close" );
                    }
                }
            });

            var d = $(".ui-dialog").position();
            window.scrollTo( d.left , d.top);
        },

        /**
         * Display Privacy Policy onclick event.
         * Called from /form/includes/general/footer_entire.php by onclick()
         */
        privacyPolicyModal : function() {
            $( "#dialog:ui-dialog" ).dialog( "destroy" );

            $( "#privacy_policy" ).dialog({
                modal: true,
                width: 800,
                title: "Privacy Policy: MyUltratrust.com",
                position: 'top',
                buttons: {
                    Ok: function() {
                        $( this ).dialog( "close" );
                    }
                }
            });

            var d = $(".ui-dialog").position();
            window.scrollTo( d.left , d.top);
        },

Open in new window


Here are the links and the onclick calls on the .pi_general plugin:

Disclaimer: Communications between you and MyUltraTrust.com are protected by our <a onclick="$().pi_general('privacyPolicyModal');" class="terms_of_use">Privacy Policy</a> but not by the attorney-client privilege or as work product. MyUltraTrust.com provides access to independent attorneys and self-help services at your specific direction. We are not a law firm or a substitute for an attorney or law firm. We cannot provide any kind of advice, explanation, opinion, or recommendation about possible legal rights, remedies, defenses, options, selection of forms or strategies. Your access to the website is subject to our <a onclick="$().pi_general('termsOfUseModal');" class="terms_of_use">Terms of Use</a>. Vertex Management Group, LLC, Riverside Center, 275 Grove Street, Building 2, Suite 400, Newton, MA, 02466 is a registered and bonded legal document assistant.

Open in new window


How do I correct the code so the modal dialog always open at the top for both links?

Thank you<><
0
Comment
Question by:Victor Kimura
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 59

Assisted Solution

by:Julian Hansen
Julian Hansen earned 2000 total points
ID: 39898438
What if you add the scrollTop to the Open?
        termsOfUseModal : function() {
            $( "#terms_of_use:ui-dialog" ).dialog( "destroy" );

            $( "#terms_of_use" ).dialog({
                modal: true,
                width: 800,
                title: "Terms of Use: MyUltratrust.com",
                position: 'top',
                buttons: {
                    Ok: function() {
                        $( this ).dialog( "close" );
                    }
                },
        open: function () {
          $(this).scrollTop(0);
        }
            });

            var d = $(".ui-dialog").position();
            window.scrollTo( d.left , d.top);
        },

Open in new window

0
 

Author Comment

by:Victor Kimura
ID: 39899188
Hi julianH,

Just tried it but that doesn't work. Any other suggestions?
0
 
LVL 59

Expert Comment

by:Julian Hansen
ID: 39899637
Yes - I made an error in my post - remove the windwo.scrollTo at the bottom i.e.
        termsOfUseModal : function() {
            $( "#terms_of_use:ui-dialog" ).dialog( "destroy" );

            $( "#terms_of_use" ).dialog({
                modal: true,
                width: 800,
                title: "Terms of Use: MyUltratrust.com",
                position: 'top',
                buttons: {
                    Ok: function() {
                        $( this ).dialog( "close" );
                    }
                },
                open: function () {
                  $(this).scrollTop(0);
                }
            });

        },

Open in new window

0
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 

Author Comment

by:Victor Kimura
ID: 39899673
Hi julianH,

No, unfortunately that didn't work either.

https://secure.myultratrust.com/diy/login/create_username.php
0
 
LVL 59

Assisted Solution

by:Julian Hansen
Julian Hansen earned 2000 total points
ID: 39899778
According to the comment here (3rd answer) the button is the cause - by adding a

$( "#terms_of_use:ui-dialog" ).focus( )

Open in new window


Claims after opening the dialog should fix the problem.
0
 

Accepted Solution

by:
Victor Kimura earned 0 total points
ID: 39905767
Hi julianH,

thanks for the link. I tried to fix it but for some reason that's not working either. So I just decided to use fancybox and that seems to work. Hopefully, jquery will fix this bug sometime in the future.
0
 

Author Closing Comment

by:Victor Kimura
ID: 39915662
Using a jquery fancybox plugin worked for me. I think it's a jQuery bug but don't have time to find out the solution right now. =(
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question