2013-08-12 5 views
0

jQuery 1.9.1 및 jQuery Mobile 1.3.2를 사용하여 웹 응용 프로그램을 개발 중입니다.jQuery 모바일 라디오 버튼

가로형 라디오 버튼에 몇 가지 문제가 있습니다. 아이콘 : data-icon="radio-on"을 표시합니다.

Radio buttons with data icon radio on

라디오 버튼은 DOM을 동적으로 추가된다.

내 HTML :

<div id="id_card"> 
    <div id="custom_properties"><h2>DATA NOT INCLUDED IN ID CARD</h2></div> 
    <div id="default_properties"><h2>ID CARD DATA</h2></div> 
</div> 

내 자바 스크립트 : 여기

var idCards = [....]; // Array of objects 

// This variable contains the HTML corresponding to the custom ID CARDS. 
var customIdCardHtml = '<ul data-role="listview" id="custom_idcard_list" data-inset="true">'; 
// This variable contains the HTML corresponding to the known ID CARDS. 
var existingIdCardHtml = '<ul data-role="listview" id="idcard_list" data-inset="true">'; 

// This variable contains the concatenation of both 'customIdCardHtml' and 'existingIdCardHtml'. 
var idCardHtml = ''; 

// Treat each ID CARD in the array 
for(var i=0; i<idCards.length; i++) { 
    // Get the current ID CARD 
    var idCard = idCards[i]; 

    // Make sure it is not null, otherwise do nothing with it 
    // and pass to the next one. 
    if(idCard) { 
     // Create an ID card line made of a label and a radio button 
     var html = '<li class="idcard_property" data-role="fieldcontain">'; 

     html += '<fieldset data-role="controlgroup" data-type="horizontal">'; 
     html += '<legend>'+idCard.NAME+'</legend>'; 

     // Populate the radio button with values 
     for(var j=0; j<idCard.VALUES.length; j++) { 
      // Get the current value of the selected ID CARD 
      var value = idCard.VALUES[j]; 
      if(idCard.VALUE == value) { 
       html += '<input type="radio" class="select_idcard_property" name="'+idCard.TAG+'" id="'+idCard.TAG+'_'+value+'" value='+value+' checked="checked">'; 
       html += '<label for="'+idCard.TAG+'_'+value+'" data-icon="radio-off">'+value+'</label>'; 
      } else { 
       html += '<input type="radio" class="select_idcard_property" name="'+idCard.TAG+'" id="'+idCard.TAG+'_'+value+'" value='+value+'>'; 
       html += '<label for="'+idCard.TAG+'_'+value+'">'+value+'</label>'; 
      } 
     } 
     html += '</fieldset>'; 
     html += '</li>'; 

     // Depending on the type of ID Card (custom or existing) 
     // append the html to a list or another 
     if(idCard.CUSTOM) 
     { 
      customIdCardHtml += html; 
     } else { 
      existingIdCardHtml += html; 
     } 
    } 
} 

customIdCardHtml+='</ul>'; 
existingIdCardHtml+='</ul>'; 

$('#custom_properties').append(customIdCardHtml); 
$('#default_properties').append(existingIdCardHtml); 

$('#id_card').trigger('create'); 

인 코드 JQM은 생성

<div class="ui-radio" style="display: block;"> 
    <input type="radio" name="TEST" id="TEST_NO" value="NO" style="display: block;"> 
    <label for="TEST_NO" data-corners="true" data-shadow="false" data-iconshadow="true" data-wrapperels="span" data-icon="radio-on" data-theme="a" data-mini="false" class="ui-last-child ui-radio-on ui-btn-active ui-btn ui-btn-corner-all ui-fullsize ui-btn-icon-left ui-btn-up-a" style="display: block;"> 
    <span class="ui-btn-inner" style="display: block;"> 
     <span class="ui-btn-text" style="display: inline;">NO</span> 
     <span class="ui-icon ui-icon-radio-on ui-icon-shadow" style="display: inline;">&nbsp;</span> 
    </span> 
    </label> 
</div> 

가 JQM에게 어떻게 spanclass="ui-icon..."에 표시되지 않도록 ?

기록을 위해 초기화시 아이콘이 표시되지 않습니다. 라디오 버튼을 클릭 할 때만 표시되고 사용자는 다른 탭으로 이동하여 라디오 버튼이있는 탭으로 돌아갑니다.

감사

+0

''를'display : none'으로 바꾸는 것은 어떨까요? – Kasyx

+0

라디오 버튼이 두 번 향상되었습니다. 아래의 답을 확인하십시오. http://jsfiddle.net/Palestinian/FUW5d/ 이것이 귀하의 코드입니다. – Omar

+0

내가 준 코드는 jQM에 의해 생성 된 코드입니다. 'display : block;'은 jQM에 의해 추가됩니다. 내 코드는 모양이 '

\t NAME \t <입력 유형 = "라디오"클래스 = "select_idcard_property"이름 = "TEST"ID와 같은 = "TEST_YES"값 = "YES"체크 = YES \t ="TEST_YES위한 "> \t <라벨"체크 " value = "NO"checked = "checked"> \t
'. – Maxbester

답변

0

는 드디어 오마르의 솔루션 $('span.ui-icon').remove();을 사용했다.

하지만 제대로 보이지 않습니다. 이것은 단지 주위의 일입니다.