0

I have a mobile web page. I am using jQuery Mobile. I have a conditional section of server side code that will produce the following section of code:

 <script type="text/javascript">    
        $(document).ready(function () {  
            var hole = "Hole" + @NextHole; // NextHole is just a server value  
            var divToGoTo = document.getElementById(hole);  
            divToGoTo.scrollIntoView(true);  
            return false;  
        })  
    </script>  

In my development desktop, IE will go to the id set by the var hole and then go to the top of the page. In my iPhone, I can't tell if it goes to the id, but still ends up at the top of the page. I'd like the user to be redirected to the id set by the var hole. I want to stop this behavior of scrolling back to the top.

I've tried other ways to do this as well. I've tried to redirect to an anchor tag using a hash on the address. I've tried the .scrollTo jquery library plugin.

It seems to me that jQuery Mobile is redirecting me to the top of the page. O've read in other places that I need to have ajaxEnabled = false;. I have this in my mobileinit method. $.mobile.ajaxEnabled = false;

How do I get a page using jQuery Mobile to go to a div tag(or other location) in the iPhone/Android? I have pulled my hair out on this and am hoping that someone can help on this. Thanks for your time.

Fahim
  • 11,496
  • 4
  • 36
  • 56
Wallace B. McClure
  • 847
  • 11
  • 24
  • 1
    Here is best advice for your answer take a look at that http://stackoverflow.com/questions/6677035/jquery-scroll-to-element – Orgil Mar 21 '15 at 15:06
  • Thanks for the link. Unfortunately, it is doing the same thing to me. The page goes back up to the top of the screen. I think that this is an issue with jQuery Mobile when the page loads that it will redirect to the top of the page. So, it's not working either. – Wallace B. McClure Mar 22 '15 at 15:57

0 Answers0