2012-07-27 2 views

답변

1

동일한 문제가 있었지만 jQuery 모바일 제한 사항에 따라 필드 세트를 이동할 수 없습니다. 그래서, jQuery를 사용하여, 나는 체크 박스를 사용하여 라디오를 모방했습니다

// add click to all checkboxes 
$(':checkbox').click(function(){ 
    // select all checkboxes with same name that are checked but not(this) 
    $(":checkbox[name='"+$(this).attr("name")+"']:checked").not(this).each(function(){ 
     // uncheck them - call checkboxradio("refresh") to update changes visually 
     $(this).attr('checked', false).checkboxradio("refresh"); 
    }); 
}); 

이 라디오에서와 마찬가지로 잘 작동합니다. .checkboxradio는 jQuery Mobile을 사용하지 않을 경우 생략해야합니다. 또한이 옵션은 확인란과 라디오 버튼이 같은 이름으로 그룹화되어 있다고 가정합니다.

은 내가 각() 블록에서하고 싶었던 몇 가지 추가 물건을 가지고 있었다. 당신이 그 요구 사항이없는 경우 짧은 버전이 가능합니다 : I는 계층 구조에서 필드 셋을 이동하여 내 현재의 문제를 해결 왔

$(":checkbox[name='"+$(this).attr("name")+"']:checked").not(this).attr('checked', false).checkboxradio('refresh'); 
5

동일한 name 속성을 부여하면 처리해야합니다.

+0

정답이어야합니다. – slick

관련 문제