-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Changing button's data-theme programatically #4317
Comments
@rskokan could you provide a test page using the latest build with jsbin or jsfiddle to illustrate? |
Hi Anne, hi @rskokan ! |
hi @rskokan The correct way of doing this is using .buttonMarkup({ theme: a }).button('refresh'); I changed this in the fiddle of @MauriceG (thanks for the fiddle!) so you can see a working example: http://jsfiddle.net/kYEBN/1/ You can read more about this here: http://jquerymobile.com/test/docs/buttons/buttons-options.html and http://jquerymobile.com/test/docs/buttons/buttons-methods.html We are working on adding examples (code + result) of manipulating content/elements to the docs. |
@MauriceG Sorry for replying late... Thanks a lot for the fiddle from me too ;-) (btw I will look at your docs PRs this weekend) @uGoMobi Thanks for the working example. Great team effort from you two! Is everyone happy for me to close? |
@agcolom - I'm going to close this as resolved, but this would be a great example to add to the docs. We need to really beef up our demos and explanation of how to do dynamic changes post-enhancement to all our widgets. Mind adding this to the button docs? |
Hi @agcolom, hi @toddparker ! |
Yes, I can see that now... |
at https://github.com/jquery/jquery-mobile/blob/master/js/jquery.mobile.forms.button.js#L45 |
@agcolom |
Hi all, sorry for the delay. You can see the example at http://jsfiddle.net/enxXQ/66/ Switching the button colors between "normal" (white) and yellow via changing their themes. When I use the buttonMarkup() (thanks @uGoMobi), it works somehow, but sometimes the color instead of being white is black :-) |
Hi @rskokan ! |
Currently nothing happens if you set the theme on the button and then call refresh. Dynamically setting the theme is part of modifying options on widgets created earlier, and is a generic problem throughout the jQuery Mobile widget set. It is addressed in #3820, but that PR is currently on the back burner until after 1.2. |
I've removed this bug from under the 1.2 milestone, because the fix is part of the on-the-fly options effort which starts after 1.2. Feel free to re-apply the milestone if this is incorrect. |
Changing the data-theme attr. for buttons dynamically from JS seems to have some issues in version 1.1.0:
Procedure
$btn.attr("data-theme", "a")
After that, I noticed the the generated div around the button contained both ui-btn-hover-e & ui-btn-up-e and also their (correct) -a variants.
It is also in case when I'm updating data-theme for the div.
So the workaround for me is to also remove the previous classes from the generated div:
The text was updated successfully, but these errors were encountered: