IBM Workligt包含所有应用程序页面的单个HTML文件:如何加载新页面? [英] IBM Workligt Single HTML file containing all application pages: How to load new page?

查看:176
本文介绍了IBM Workligt包含所有应用程序页面的单个HTML文件:如何加载新页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用IBM Workligth开发一个hypbrid应用程序,其中包含一个包含所有应用程序页面的html文件,例如:

Im developing a hypbrid app using IBM Workligth, with a single html file containing all application pages, like:

<div data-role="page" id="page1">

//page1 specific

</div>

<div data-role="page" id="page2">

//page2 specific

</div>

如何在页面之间切换?看起来这应该很简单,但我不知道如何。

How do I switch between the pages? It seems like this should be really simple, but I can't find out how.

提前致谢。

推荐答案

您可能还应该提到您在HTML标记中使用jQuery Mobile( data-role 属性...),因为这是你问题的关键。

You should probably also mention that you are using jQuery Mobile (data-role attribute in your HTML tags...), because that's the key to your question.

jQuery Mobile提供了创建多页面应用程序的能力。有两种方法:

jQuery Mobile provides the ability to create multi-page applications. There are two approaches:


  • 包含DIV的单个HTML文件,其中每个DIV都是页面

  • 多个HTML文件,每个HTML文件都是页面

您应该考虑上述方法之一,具体取决于方式重你的应用程序将会是多少页(每页的内容等等)。

You should consider one of the above approaches, depending on how "heavy" your app is going to be (how many pages, the contents of each page, etc...).

jQuery Mobile的文档网站解释了上述概念: http://demos.jquerymobile.com/1.4.3/pages/

jQuery Mobile's documentation website explains the above concept: http://demos.jquerymobile.com/1.4.3/pages/

jQuery Mobile提供了一种名为的API方法changePage 。使用它,您将能够在页面之间遍历。

jQuery Mobile provides an API method called changePage. Using it, you will be able to traverse between "pages".

例如:

点击一个按钮将显示另一个页面 (这里是DIV)。

For example:
A button then when tapped will show another "page" (here, a DIV).

<a href="#" data-role="button" id="button" onclick="$.mobile.changePage('page2', {transition: 'flip'})">load page2</a>






在Worklight应用程序的上下文中,您必须请记住,Worklight是一个单页面应用程序,这意味着在页面之间导航必须以使Worklight框架保持循环的方式完成,否则Worklight功能将停止运行。


In the context of a Worklight application, you must keep in mind that Worklight is a single-page application, meaning that navigating between "pages" must be done in a way that keeps the Worklight framework in the loop, otherwise Worklight features will stop functioning.

我建议浏览一下过去关于这个主题的各种问题: https://stackoverflow.com/search?q=%5Bworklight%5D+multipage+is%3Aquestion

I suggest to skim through the various past questions on this topic: https://stackoverflow.com/search?q=%5Bworklight%5D+multipage+is%3Aquestion



最后,这里有一些示例Worklight 6.1项目:


Finally, here are some example Worklight 6.1 projects:

  • https://www.dropbox.com/s/8f0xr9ogp4ofuqs/JQM_multipage_changePage_pageshow.zip
  • https://www.dropbox.com/s/a4kocwo205s049b/JQM_multipage_load_changePage.zip

这篇关于IBM Workligt包含所有应用程序页面的单个HTML文件:如何加载新页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆