Creating dynamic form elements with jQuery Mobile
jquery, jquery-mobile
Solution
check this fiddle http://jsfiddle.net/YUvG9/ or check an update of yours http://jsfiddle.net/4V3Tm/4/ maybe the problem is you call `.trigger('create')` many times
$(document).on('pageinit', '#home', function () {
var current = 3;
$('#home input[type=button]').click(function () {
current++;
$('#choices .ui-controlgroup-controls')
.append(
$('<input/>', {
'type': 'radio',
'name': 'choice',
'id': 'choice' + current,
'value': current,
'data-theme': 'd'
})
.append(
$('<label/>', {
'for': 'choice' + current
})
.text('Choice ' + current)
)
);
$("#home").trigger('create')
});
});
Problem
Ok, perhaps that was answered before, but I wasn't able to found anything through search... I'm new to jQuery Mobile and I'm trying to dynamically add radioboxes to one `<fieldset>` container through a page, as you can see in this fiddle: http://jsfiddle.net/4V3Tm/4/ It's working. But for some reason I don't know, dynamically added choices didn't get styled as normal radioboxes. Am I missing something? BTW, shouldn't them all expand to the page width? (well, I'm totally noob yet...) Thank you in advance.