Filed in the "In case you need to know" department, jQuery Mobile provides a basic API that allows you to modify buttons. This is more useful for creating new buttons, but also has uses for existing buttons. Specifically, I was looking for a way to swap out the theme of a button in a form based on what had been entered. Here is a simple example of this API in action:
Not directly relevant to your post but related and may be helpful to others creating buttons dynamically with jqm.
I was having trouble adding the decorations to a dynamically created button.
The step I was missing was adding $("#mynewbutton").button() after emitting the html.
Thanks for this post. I notice in your demo that the button you are clicking on (either one) does not get the theme change, except for theme 'e' (I have no idea why just 'e' works). I imagine this is because of the associated events that are repainting the button back to the default theme. It would be super if you could find a way to make it work! Thanks.
Hmpth. That is interesting. I believe .. oh... just try switching click to touchend. Let me know if that works.