Reputation: 16946
I am trying to add some buttons into my jquery mobile page via ajax.
Straight injection into the page doesnt style it at all.
Trying this also does not work (doesnt get styled)
$('<a href="#" data-role="button" id="next_page">Next</a>').appendTo('#page_btns').trigger('create');
Here is the code for its div
<div data-role="controlgroup" data-type="horizontal" id="page_btns"></div>
How can I add/remove grouped buttons via AJAX using jquery mobile?
EDIT: Calling .trigger('create') on the controlgroup div does style the buttons, but they are set to single buttons rather then the grouped style
Upvotes: 0
Views: 1158
Reputation: 13620
Trigger create event on any div enclosing the controlgroup.For eg:data-role=content
div.
Add the following line of code after you append buttons to div
$('div[data-role=content]').trigger('create');
Upvotes: 4