Changing Themes: Difference between revisions
Jump to navigation
Jump to search
Created page. |
Added a check for missing class attributes. |
||
Line 8: | Line 8: | ||
Function changeTheme(index) | Function changeTheme(index) | ||
$(this).data("theme", "c") | $(this).data("theme", "c") | ||
classList = $(this).attr("class").split(" ") | classList = $(this).attr("class") Or "" | ||
classList = classList.split(" ") | |||
For i = 0 To classList.length - 1 | For i = 0 To classList.length - 1 | ||
If classList[i].slice(0, 3) = "ui-" And classList[i].slice(-2) = "-a" Then | If classList[i].slice(0, 3) = "ui-" And classList[i].slice(-2) = "-a" Then |
Latest revision as of 18:36, 11 July 2013
You can dynamically change the theme of a JQuery Mobile control at runtime. This example shows changing the theme of a control called List1 from a to c upon a button click:
Function Button2_onclick() $("#List1, #List1 *").each(changeTheme) End Function Function changeTheme(index) $(this).data("theme", "c") classList = $(this).attr("class") Or "" classList = classList.split(" ") For i = 0 To classList.length - 1 If classList[i].slice(0, 3) = "ui-" And classList[i].slice(-2) = "-a" Then $(this).removeClass(classList[i]) $(this).addClass(classList[i].slice(0, -2) & "-c") End If Next End Function