jQuery mobile Tabs and Anchors

我怕爱的太早我们不能终老 提交于 2019-12-02 07:31:06

I think I understand but feel free to comment if I'm misunderstanding your question.

I believe you're misunderstanding how internal JQuery linking works. First thing is take a look at the JQuery Mobile page anatomy, especially at the "Multi-page template structure" in your case: http://jquerymobile.com/test/docs/pages/page-anatomy.html

Basically every "embedded in the middle of page" section of your page will need to be a stand alone div marked with the data-role="page" tag. Its ID is going to be what you'll point an anchor to.

So in order for your internal <a href="#jib"> to work you have to have a built in div with ID = "jib"

UPDATED ANSWER AFTER COMMENTS

What you're looking for is $.mobile.silentScroll . You want to get your anchor link's Y-position and then have the page scroll to it. There is a little gotcha though. You'll need to add a little pause before the scroll happens because of the JQuery Mobile animations that happen on page transition.

function loadJib()
{
  $.mobile.changePage('#jib',{transition:"slide"});

  var yPos = $('#mylink').get(0).offsetTop;

  setTimeout(function(){
    $.mobile.silentScroll(yPos);
  },800);

Take a look how I did it ( .8 second delay ).:

http://jsbin.com/ahevav/3/edit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!