I want to change a jquery-mobile buttons color swatch dynamically with javascript, but I can't' find a way (except removing and adding all classes and event handlers, but that's to messy).
Whats the best way to do that?
相关问题
- Jquery mobile dual range slider reload with new ra
- jquery-mobile still “No Back Button” (Beta 2)
- How to use font awesome icons in jQuery mobile but
- jQuery Mobile header button float left and right
- Jquery Mobile: Getting a cancelled Postback that
相关文章
- Checking & Unchecking Checkboxes inside a JQuery M
- How to make a default custom theme with ggplot2 in
- jQuery ajax call returns empty error if the conten
- google map not full screen after upgrade to jquery
- How To Calling a Stored Procedure in Worklight
- jquery mobile page indicator (dots)
- Removing round corners from the button in jquery m
- jquery mobile change to the next and previous data
I use this and it works perfectly !! :D
Mikael Kindborg answer from Change data-theme in jQuery mobile
Well I did do something like this:
JS (might need minor tweaks to get what you want)
HTML (might need minor tweaks to get what you want)
At least in 1.2.0 (1.2.0-rc1) its as simple as (probably it works in minor versions):
$( "#myButton" ).buttonMarkup({theme: 'd'});
not
.button('refresh')
neededYes, looks like there is no way to simply change the theme swatch.
I hacked a simple function to exchange the color by regex:
I know, it should use
jqmData
instead ofattr
, but the data-theme attribute wasn't changed properly.Buttons need to have the parent element theme changed as well.
Add the following code to the end of the $.fn.changeColorSwatch function
What worked for me is:
Adding the class 'ui-btn-active' to the parent will set the current button to active and change the data-theme to 'b'. This will not work for any arbitrary swatch though. So you may still need one of the longer solutions mentioned earlier.