struts2-jsp 응용 프로그램을 만들었습니다. 대화 상자 팝업창이 나타납니다. 클릭 할 때 하이퍼 링크를 편집 할 때마다 Jquery를 사용하여 편집 하이퍼 링크를 클릭 할 때 팝업 창이 나타납니다. . 첫 번째 편집을 클릭했을 때만 대화 상자가 팝업되고, 두 번째 및 다른 편집에서 레코드가 추가 될 때 동적으로 생성되는 대화 상자가 팝업되지 않는 문제가 있습니다.jquery : 동적으로 생성 된 테이블에 대화 상자가 표시되지 않습니다.
JQuery와 코드는 다음과 같습니다
<script>
$(document).ready(function(){
$("#todo").dialog({ autoOpen: false });
$("#dialogLink").click(function() {
$("#todo").dialog('open');
});
});
</script>
동적으로 테이블을 생성하는 코드는 다음과 같습니다
<div class="content">
<table class="todoTable" cellpadding="5px">
<tr class=even>
<th>TITLE</th>
<th>STATUS</th>
<th>EDIT</th>
<th>DELETE</th>
</tr>
<!--This will iterate through the todolist -->
<s:iterator value="gettodoList()" status="todoStatus">
<tr class="<s:if test="#todoStatus.odd == true ">odd</s:if> <s:else>even</s:else>">
<td><s:property value="title" /></td>
<td><s:property value="complete" /></td>
<!-- This will append the Id with the url -->
<td>
<a id="dialogLink" href="#">Edit</a>
</td>
<td><s:url id="deleteURL" action="deleteTodo">
<s:param name="id" value="%{id}"> </s:param>
</s:url> <s:a href="%{deleteURL}">Delete</s:a>
</td>
</tr>
</s:iterator>
</tbody>
</table>
</div>
[동적으로 생성 된 요소에 이벤트 바인딩?] (http://stackoverflow.com/questions/203198/event-binding-on-dynamically-created-elements) – vijayP
또한 중복 될 수 없습니다. 단일 문서. 'id' 대신'class'를주고, 이벤트 위임 기법을 통해 bind 이벤트를 시도해보십시오. – vijayP
테이블을 업데이트 한 후 jquery 코드가 실행되는지 확인하십시오. 아마도 jquery 코드는 처음에 한 번만 실행됩니다. – Chandru