I just started using a jquery mobile custom theme instead of one of the defaults. Lots of issues...but the current one is that dynamically created buttons don\'t work as expecte
data-role=button
is deprecated so you need to add classes manually and it doesn't require any manual enhancement even if you append them dynamically. .button()
is used for <input type=button>
only.
Your solution is as follows:
var Btn = '<a href="#" class="ui-btn ui-btn-Custom ui-btn-icon-Position ui-icon-Name">Button</a>';
$(".selector").append(Btn);
ui-btn-Custom
: is theme swatch i.e. ui-btn-a
ui-btn-icon-Position
: icon's position, left,right,top,bottom or notext i.e. ui-btn-icon-left
ui-icon-Name
: icon's image i.e. ui-icon-home
Demo