0
동적으로 생성되는 라디오 버튼을 jQuery Mobile 컨트롤 그룹으로 그룹화하는 데 문제가 있습니다. 라디오 버튼을 생성하고이를 라디오 버튼에 추가합니다. separetly dispalayed 뒤틀림이 'controlgroup'데이터 역할이 포함되어 있지만, 여기 내 HTML입니다 :동적으로 생성 된 라디오 버튼을 jQuery Mobile에서 '컨트롤 그룹'으로 그룹화하는 방법
<div data-role="collapsible" data-inset="true">
<h1>AddVote</h1>
<div data-role="fieldcontain" >
<form id="voting" action="get">
<label for="name"> <strong>Question:</strong></label>
<input type="text" name="name" id="name" value="" /><br>
<label for="name"><div id="AddButton" data-role="button" data-inline="true">AddOptions</div></label>
<input type="text" name="option" id="option" value="" /><br>
<div id="RemoveButton" data-role="button" data-inline="true">RemoveOptions</div>
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<legend> <strong>Choose an Option:</strong></legend><br><br>
<fieldset data-role="controlgroup">
<div id="after" data-role="controlgroup" >
///////////////////////Generated radio buttons goes here//////////////////////
</div>
</fieldset>
</fieldset>
</div>
</div>
<a href="#" data-role="button" data-inline="true" >Publish</a>
</form>
여기에 스크립트 코드입니다 : 내가 제대로 질문을 이해하지 아마도
function createRadioElement(elem, label, checked) {
var id = 'option1_' + label;
$('#after').append($('<input />', {
'type': 'radio',
'name': 'option1',
'id': id,
'data-role': 'controlgroup',
'data-theme':'e',
'value': '1'
}));
$('#after').append('<label for="' + id + '">'
+ label + '</label><br />').trigger('create');
}
$('#admin').live('pageinit',function(event){
$('#AddButton').click(function(){
var x = document.getElementById('option').value;
createRadioElement(this,$('#option').val(),true);
});
감사합니다. @ahdaniels –