什么是“移动页面容器"?选择器 [英] What is the "mobile-pagecontainer" selector

查看:18
本文介绍了什么是“移动页面容器"?选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jQuery Mobile 有各种事件和方法.pagecontainer 事件和方法用于处理 v1.4 中的大部分 page 事件.我不明白 :mobile-pagecontainer 选择器的用法.

jQuery Mobile has various events and methods. The pagecontainer events and methods are used to handle most of the page events from v1.4. I do not understand the use of the :mobile-pagecontainer selector.

API 文档仅使用 $('.selector') ,虽然简单易懂,但我不知道它指的是哪个对象.我应该在 $('div[data-role="page"]')$('body') 上使用它.另一个选择器 :mobile-pagecontainer 表示什么?

The API documentation only uses $('.selector') which is straightforward and simple to understand though, I do not know which object it is referring to. Am I supposed to use it on a $('div[data-role="page"]') or on $('body'). And what does the other selector, :mobile-pagecontainer, signify?

API:jQuery 1.4.0 API

另外,我在 stackoverflow 和其他网站上发现了很多使用 $(document) 的例子,这与所有这些有什么关系?

Also, I found many examples on stackoverflow and other websites using $(document) what is the relation to all these?

编辑 2:我创建了一个小小提琴,它使用所有 3 个选择器 $('body'), $(':mobile-pagecontainer')$(document)Fiddle - PageContainer 事件.我的心感谢@Omar

Edit 2: I created a tiny fiddle which exhibits the pagecontainerbeforeshow event using all the 3 selectors $('body'), $(':mobile-pagecontainer') and $(document)Fiddle - PageContainer Events. My heart felt gratitude and thanks to @Omar

推荐答案

$(":mobile-pagecontainer") 是一个选择器,它指的是parent元素,包括内部页面和外部页面.

$(":mobile-pagecontainer") is a selector, it refers to the parent element of jQM pages, both internal pages and external ones.

默认情况下,:mobile-pagecontainerbody.它也可以称为 $.mobile.pageContainer(pageContainer 中的大写字母C").

By default, :mobile-pagecontainer is body. It also can be referred to as $.mobile.pageContainer (mind capital "C" in pageContainer).

.pagecontainer() 是一个函数,用于更改加载页面,以及检索活动页面.

.pagecontainer() is a function that is used to change and load pages, as well as retrieve active page.

简而言之,$(":mobile-pagecontainer") = $.mobile.pageContainer = $("body") (默认).

In short, $(":mobile-pagecontainer") = $.mobile.pageContainer = $("body") (default).

:mobile-pagecontainer 的值可以在 mobileinit 上被覆盖,以防你想用与 body 不同的元素包装页面.

The value of :mobile-pagecontainer can be overridden on mobileinit, in case you want to wrap pages in a different element than body.

$(document).on("mobileinit", function () {
  $.mobile.pageContainer = $("#foo");
});

  • 更改页面(假设 foo 是容器):

    $("#foo").pagecontainer("change", "#pageID or URL");
    

  • 加载外部页面:

    $("#foo").pagecontainer("load", "URL");
    

  • 要检索活动页面:

    $("#foo").pagecontainer("getActivePage");
    

  • 这篇关于什么是“移动页面容器"?选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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