2012-12-27 1 views
1

도움이 필요합니다.Ajax 및 Combox 생성

<div id="contentAccionFormativa" class="displayAF">   
        <display:table id="displayAF" name="${accionesFormativasList}"                
            htmlId="justifAfList" 
            class="displayTagTable" 
            uid="accionFormativa">  
         <display:column titleKey="asociarJustificante.display.af.header.checkbox"          
             class="tdBorderFirst center" 
             headerClass="firstTh" 
             style="width: 2px;" >       
          <form:checkbox id="checkAf" path="listaIdAccionesFormativas" value="${accionFormativa.idAfExteInteIdConv}"/> 
         </display:column> 
         <display:column titleKey="asociarJustificante.display.af.header.descripcion" class="lastTh center" > 
          ${accionFormativa.codAF} 
         </display:column> 

         <display:footer> 
          <tr><td colspan="2" class="firstTh lastTh right"></td></tr> 
         </display:footer> 
        </display:table> 
       </div> 

내가 가진 카운트 체크 박스를 해보 :

나는 테이블과 displaytag에 의해 생성이

jQ('#justifAfList :checkbox').click(function() { 
     alert(jQ("input:checked").length); 
    }); 

오기 '가 잘 작동하지만 내가 함께 아약스와 테이블을 생성 할 때 :

jQ.each(data.ajaxResult.accionesFormativas, function(i,value){ 
        firstTd = "<td class='tdBorderFirst center' style='width: 2px;'><input id='checkAf' type='checkbox' value=" +value.idAfExteInteIdConv+ " name='listaIdAccionesFormativas'><input type='hidden' value='on' name='_listaIdAccionesFormativas'></td>"; 
        jQ('#justifAfList > tbody:last').append("<tr class='odd'>" + firstTd + "<td class='lastTh center'>" + value.codAF +"</td></tr>"); 
       }); 

jquery 기능은 첫 번째 확인란의 클릭 만 캡처합니다.

누군가 나를 도울 수 있습니다.

답변

1

봅니다 기존 개체에 이벤트를 위임 :

jQ('#justifAfList').on('click','input:checked',function() { 
    alert(jQ("input:checked").length); 
}); 

하거나, 경우에 당신은, 1.7보다 낮은 버전으로 작업 '라이브'를 사용.

+0

정말 대단합니다. 이것은 완벽하게 작동합니다. – user1821460