最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What is the "mobile-pagecontainer" selector - Stack Overflow

programmeradmin6浏览0评论

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.

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

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

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

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.

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

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

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

Share Improve this question edited Jun 11, 2014 at 23:25 Lordbalmon asked Jun 11, 2014 at 22:47 LordbalmonLordbalmon 1,7141 gold badge15 silver badges32 bronze badges 2
  • 1 I know, and I have knocked on his door many a times and ready to read even a 10 page document, but could not find one. @NonameBilly, kindly suggest any document if you have found any :) – Lordbalmon Commented Jun 11, 2014 at 22:52
  • Lol, I like how you phrased that. – user3117575 Commented Jun 11, 2014 at 22:54
Add a comment  | 

1 Answer 1

Reset to default 21

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

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

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

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

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");
});
  • To change pages (assuming foo is the container):

    $("#foo").pagecontainer("change", "#pageID or URL");
    
  • To load an external page:

    $("#foo").pagecontainer("load", "URL");
    
  • To retrieve active page:

    $("#foo").pagecontainer("getActivePage");
    
发布评论

评论列表(0)

  1. 暂无评论