For some reason, your setting of data-type="horizontal" is getting erased when you try to dynamically push a tags into the controlgroup. SO i tried setting those values again through code like this :
$('#ctrl').controlgroup({
type: "horizontal",
corners: false
});
Then, trigger a create on the page:
$("#frontPage").trigger('create');
This seems to work. I'll look more into this and get back to you. But for now, here's a working demo : http://jsfiddle.net/saQFx/3/
Changes made
- removed the data-role from html and initialized
controlgroup from JS
- changed
append() to html()
- added
trigger('create'); at the end.
- removed
button(). This ain't needed anymore. If you're doing a lot of changes together, like you're doing now,its wiser to call create on page.
An alternative though would be to inject the entire control group with all its contents through javascript, then run a trigger('create') on your page.
EDIT
Unfortunately, when you init controlgroup through the JS way, the rounded corners aren't kicking in by themselves. Guess you have to add ui-corner-all class by yourself to this, I just didnt want to get into that. That's a whole new level of mess. SO, instead of that, you could try the second method I mentioned:
- injecting the entire control structure through JS itself
- trigger the
create method of page in the end.
Here's a demo : http://jsfiddle.net/hungerpain/saQFx/8/
Hope this helps!