이 질문에 대한 변형을 보았지만 SO에 대한 특정 사례는 보았으므로 여기에 있습니다.
jQuery Mobile을 사용하여 기존 제어 그룹에 동적으로 새 라디오 입력을 추가하는 데 문제가 있습니다. 추가되지만 스타일이 올바르지 않으며 다른 입력과 올바르게 상호 작용하지 않는 것 같습니다.
여기 내 바이올린이 있습니다. http://jsfiddle.net/cjindustries/3mQF6/
아무도 내가 뭘 잘못하고 있는지 볼 수 있습니까? 아니면 전체 fieldset / controlgroup을 다시 생성하는 경우입니까? :(
감사! 아래 코드도 ...
<div id="testPage" data-role="page">
<div data-role="content">
<fieldset data-role="controlgroup">
<legend>Radio buttons, vertical controlgroup:</legend>
<input type="radio" name="radio-choice-1" id="radio-choice-1" value="choice-1" checked="checked">
<label for="radio-choice-1">Cat</label>
<input type="radio" name="radio-choice-1" id="radio-choice-2" value="choice-2">
<label for="radio-choice-2">Dog</label>
<input type="radio" name="radio-choice-1" id="radio-choice-3" value="choice-3">
<label for="radio-choice-3">Hamster</label>
<input type="radio" name="radio-choice-1" id="radio-choice-4" value="choice-4">
<label for="radio-choice-4">Lizard</label>
</fieldset>
</div>
</div>
$('<input type="radio" name="radio-choice-5" id="radio-choice-5"><label for="radio-choice-5">Horse</label>')
.appendTo("fieldset");
$("fieldset").trigger('create');
name="radio-choice-1"
위에서 사용한대로 사용해야 합니다. 이것은 당신의 행동 문제를 해결합니다
아래 변경으로 해결 된 동작 문제 동적으로 라디오를 추가하기 위해 수정 된 코드.
$('<input type="radio" name="radio-choice-1" id="radio-choice-5"><label for="radio-choice-5">Horse</label>').appendTo("fieldset");
아래 변경으로 해결 된 스타일 문제 그냥 fieldset 대신 div를 다시 만드십시오.
$("div").trigger('create');
Fiddle 데모 확인
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다