JQuery unable to change themes

JQuery unable to change themes

Hi,

I have a couple of buttons that when clicked, they change between themes "a" and "b", I'm using this script to change themes:

 
  1. <script>
  2. $(document).ready(function() {
  3. $("#blueThemeButton").click(function() {
  4. $('[data-role=page]').page({theme:'a'});
  5. });

  6. $("#greenThemeButton").click(function() {
  7. $('[data-role=page]').page({theme:'b'});
  8. });
  9. });
  10. </script>

This works as expected when change from theme "a" to theme "b", but it doesn't work if theme "b" is applied and I want to change back to theme "a".

Looks like I can only move forward in the themes list, I tried removing the previous theme before applying the new one by adding this line before applying the themes:

 
  1. $("body").removeClass();

I also tried:

 
  1. $("#page").removeClass();

The first line doesn't have any effect and the second one removes everything from the page, it just leaves an empty blank page.

How can I remove the current theme before applying another? Is this the correct way to do it?

Thanks!