Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix for displaying sub-pages as dialogs. Also cleaned up some white s…

…pace for consistency with rest of source.
  • Loading branch information...
commit 92ec5688cbb661b458e17e08280d90de0b431600 1 parent 7a82bc8
@adammessinger adammessinger authored
Showing with 19 additions and 8 deletions.
  1. +19 −8 jquery.mobile.subpage.js
View
27 jquery.mobile.subpage.js
@@ -24,7 +24,7 @@
* Subpages are detached from parent page and added/removed to/from the DOM.
* The functionality provided by this widget is a workaround for the jQuery Mobile
* loadPage() function which only loads the first page in an AJAX response.
-*/
+*/
(function ($, undefined) {
@@ -33,7 +33,7 @@
$.widget("mobile.subpage", $.mobile.widget, {
options: {
- initSelector: ":jqmData(role='subpage')"
+ initSelector: ":jqmData(role='subpage'), :jqmData(role='subpage-dialog')"
},
_create: function () {
@@ -62,21 +62,32 @@
var subpageUId = subpageId || ++subpageCountPerPage[parentId];
var subpageId = subpage.attr("id") || subpageUId;
+ var subpageType = subpage.jqmData("role");
+ var subpageContent = subpage.find(":jqmData(role='content')");
var subpageUrl = (parentUrl || "") + "&" + $.mobile.subPageUrlKey + "=" + subpageUId;
var newPage = subpage.detach();
newPage
.attr("data-" + $.mobile.ns + "url", subpageUrl)
- .attr("data-" + $.mobile.ns + "role", 'page')
- .appendTo($.mobile.pageContainer);
+ .attr("data-" + $.mobile.ns + "role", 'page');
+ // work-around for dialogs not getting default content theme of "c"
+ if (subpageType === "subpage-dialog" && subpageContent.jqmData("theme") === undefined) {
+ subpageContent.attr("data-" + $.mobile.ns + "theme", 'c');
+ }
+ newPage.appendTo($.mobile.pageContainer);
- newPage.page();
+ if (subpageType === "subpage") {
+ newPage.page();
+ }
+ else {
+ newPage.dialog();
+ }
// on pagehide, remove any nested pages along with the parent page, as long as they aren't active
// and aren't embedded
if (parentPage.is(":jqmData(external-page='true')") &&
- parentPage.data("page").options.domCache === false) {
+ parentPage.data("page").options.domCache === false) {
var newRemove = function (e, ui) {
var nextPage = ui.nextPage, npURL;
@@ -92,8 +103,8 @@
// unbind the original page remove and replace with our specialized version
parentPage
- .unbind("pagehide.remove")
- .bind("pagehide.remove", newRemove);
+ .unbind("pagehide.remove")
+ .bind("pagehide.remove", newRemove);
}
},
Please sign in to comment.
Something went wrong with that request. Please try again.