动态添加页面的jQuery移动网络应用程序 [英] Dynamically add pages to jQuery mobile web app

查看:102
本文介绍了动态添加页面的jQuery移动网络应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MVC4 Web应用程序需要12 jQuery Mobile的页面。

I have an MVC4 web app that needs 12 jQuery Mobile pages.


  1. 欢迎

  2. 登录

再等等。

我想在一次添加一个网页,如果用户要求它,

I want to add one page at time if the user request it,


  1. 什么是最好的方法,动态页面添加到我的项目?

  1. What is the best approach to add pages dynamically to my project?

哪里是合适的网站,包括网页脚本(即页面动态添加)?

Where is the appropriate site to include the page scripts (that pages added dynamically)?

究竟意味着数据的ajax =false表示它被包含在 Html.ActionLink()

What exactly mean data-ajax="false" if it was included in a Html.ActionLink()?

这时我有我的应用程序的近90%,但我有一些引用页面严重的问题,有的时候包括在视图中的所有网页渲染鸵鸟政策或鸵鸟政策运行脚本。

At this time I have almost 90% of my app, but i'm having serious problems referencing some pages, some times all pages included in a view don´t render or don´t run the scripts.

推荐答案

我认为你必须在组织jQuery Mobile的页面下面的选项:

I think you have the following options in organising JQuery Mobile pages:

(a)一种HTML文件的所有页(类的div =网页)

(a) one HTML file with all the pages (divs with class="page")

这是最简单的方法,并保证然而工作文件可能成为一个大项目

This is the simplest approach and guaranteed to work however the file might become too large for a big project

(二)一个主HTML文件链接到孩子的HTML文件

(b) one main HTML file linking to child HTML files

从一个UI的角度看,加载子页面,这使得过渡作为流体时JQM默认使用AJAX模式作为选择(a)。这样做的缺点是,子页不完全加载,即,没有其包括或脚本被执行。在负荷,JQM解析使用类=页的第一个div的子页面,提取的div并将其添加到当前的DOM。请注意,子页面不能有多个页,因为只有第一个将被载入。

From a UI standpoint, JQM by default uses "AJAX mode " when loading a child page, which makes transition as fluid as option (a). The drawback of this is that child pages are not fully loaded, ie, none of its includes or scripts are executed. On load, JQM parses the child page for the first div with class="page", extracts the div and adds it to the current DOM. Note that a child page cannot have more than one "pages" since only the first one will be loaded.

要做到选项(二)正确,你可以:

To do option (b) correctly, you could:


  1. 包括所有的CSS,JS和运行在主网页的所有初始化脚本或

  1. include all CSS, JS and run all init scripts in the main page or

指定数据AJAX虚假=或相对=外部你的链接。这迫使JQM完全重新加载链接/子页面,但是这种方法你就失去了流动的过渡。

Specify "data-ajax=false" or "rel=external" on your links. This forces JQM to fully reload the linked/child page, however with this approach you lose the fluid transition.

这篇关于动态添加页面的jQuery移动网络应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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