Here is a way to do it, by extending
page
widget. I had no time to track the issue on jQM master files, but I
will definitely do it tomorrow.
-
(function($, undefined) {
-
$.widget("mobile.page", $.mobile.page, {
-
theme:
function(c) {
-
var page = this.element,
-
currentThemes = this.element.attr("class").match(/\S+-page-theme-\S+/g);
-
if (currentThemes.length > 1) {
-
var cTheme = currentThemes[currentThemes.length - 1];
-
}
-
currentThemes.forEach(function(theme) {
-
page.removeClass(theme);
-
});
-
page.addClass("ui-page-theme-" + c);
-
}
-
});
-
})(jQuery);
To change theme, just call
.page("theme", "swatch")
on active page
This will remove any class beings with
ui-page-theme-
and replace it with desired swatch.
Demo:
https://jsfiddle.net/Palestinian/x0ka1Ls9/