동적으로 추가 된 체크 박스/라디오 버튼/등급 요소가 의미있는 UI에서 연결된 이벤트를 시작하지 않습니다. 아래 샘플에 대한 js 바이올린 및 이벤트를 트리거하는 모든 확인란을 선택했을 때 나는 '설정'옵션과 onChange 별도로뿐만 아니라 시도했다. 아무것도 예상대로 작동하지 않습니다. 자바 스크립트 :동적으로 추가 된 semanctic UI 확인란/라디오/등급 이벤트가 실행되지 않음
$("#cbdiv").checkbox('setting', 'onChange', function() {
alert("Changed");
});
$("#addcheckboxes").unbind();
var chkcounter = 0;
$("#addcheckboxes").bind('click', function() {
$('#chkgrp').append("<div id='chkbx_'" + chkcounter + "class='ui checkbox'><input type='checkbox' ></div>");
$('#chkbx_' + chkcounter).checkbox({
onChange: function() {
alert('i am added. my id is : ' + $(this).attr('id'));
}
});
});
HTML은
<div class="field">
<div id="cbdiv" class="ui toggle checkbox">
<input type="checkbox" id="confirm" name="confirmed">
<label>Confirmed</label>
</div>
<div>
<button id="addcheckboxes">Add checkboxes</button>
<div id="chkgrp">
</div>
</div>
</div>
다음은 업데이트 된 피들입니다. http://jsfiddle.net/tummgh41/79/ –