I am creating a mobile web applications using jQuery Mobile.
I am using theme-b
for every page and I would like to change to another theme dynamically for every page. How can I change the theme dynamically?
I am creating a mobile web applications using jQuery Mobile.
I am using theme-b
for every page and I would like to change to another theme dynamically for every page. How can I change the theme dynamically?
Rajesh's answer helped me a lot... But Rajesh, you missed an important class ---- 'ui-page-theme-*', so I modified your answer and now it's perfect for jQuery Mobile 1.4.5 (again)...
The above answer helped me a lot, I modified it a little for my need, as I am using themeroller and expect to have more than 20 themes. Here is what I have done
Now when I get the new Theme from the server via json I just call this method with the new theme as param.
Regards Rajesh J
You can target specific classes that relate to specific widgets, reset their classes, and then add the themed class of your choosing:
http://jsfiddle.net/VNXb2/1/
This is by no means a fully functional code snippet, you will need to find any other widgets that you want updated when you switch the theme and add them to the code above. You can find what classes each widget has easily by using FireBug or another Developer Console.
UPDATE
When you take into account the
data-role="list-divider
elements this gets a little tricky:Here is a demo: http://jsfiddle.net/VNXb2/7/