Changing Themes

From NSB App Studio
Revision as of 08:11, 11 July 2013 by James (talk | contribs) (Created page.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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").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