如何在jQuery移动多页面模板结构中将第二页显示为默认页面?

如何在jQuery移动多页面模板结构中将第二页显示为默认页面?

 

Foo

I'm first in the source order so I'm shown as the page.

Home

I'm the second in the source order so I'm hidden when the page loads. I'm just shown if a link that references my id is beeing clicked.

Bar

I'm the second in the source order so I'm hidden when the page loads. I'm just shown if a link that references my id is beeing clicked.

工作示例: http : //jsfiddle.net/Gajotres/UfDaf/

使用的代码

这部分将阻止正常的页面加载。 不要忘记,就像在我的例子中一样, 必须jQuery Mobile初始化之前初始化mobileinit。

 $(document).on("mobileinit",function() { $.mobile.autoInitializePage = false; }); 

这部分将启动手册页初始化:

 $(document).ready(function() { window.location.hash = 'home'; $.mobile.initializePage(); }); 

虽然我通常建议不要使用文档就绪,但我们需要它来启动手动更改。

完整的代码示例

如果jsFiddle了。

HTML:

    jQM Complex Demo         

Foo

I'm first in the source order so I'm shown as the page.

Home

I'm the second in the source order so I'm hidden when the page loads. I'm just shown if a link that references my id is beeing clicked.

Bar

I'm the second in the source order so I'm hidden when the page loads. I'm just shown if a link that references my id is beeing clicked.

Javascript:

 $(document).ready(function() { window.location.hash = 'home'; $.mobile.initializePage(); }); 

我知道这个问题有点旧,但我偶然发现了一个简单的解决方案:

 window.location.href = "https://stackoverflow.com/questions/16733573/how-to-show-the-second-page-as-the-default-page-in-a-jquery-mobile-multi-page-te/_dash.html"; 

或者,如果您从单独的页面导航,您可以在第二页中创建一个链接,如下所示:

 link to second page 

只需在url末尾添加第二页的页面ID即可