여기에 2 개의 html이 있습니다. 첫 번째는 PHP에 의해 동적으로 생성되고 두 번째 것은 테스트 할 html입니다.jquery로 동적으로 작성한리스트를 삭제할 수 없습니다
다음 jquery도 있습니다.
두 번째 클래스 (일반 html)에서 클래스 삭제가있는 교차를 클릭하면 잘 작동합니다. 그러나 처음 것에서 십자가를 클릭하면 작동하지 않습니다. 끝 부분에 #이있는 홈 페이지로 리디렉션됩니다.
누군가 내가 잘못하고있는 것을 지적하고 싶습니다.
감사합니다. 여기
HTML
First part (dyanmicall generated)
<ul style="display: block;" id="message">
<li class="41">
<span class="user"><strong>shin</strong></span>
<span class="msg"> delete this as well</span>
<span class="date">2010-01-15 07:47:31</span>
<a href="#" id="41" class="delete">x</a>
<div class="clear"></div></li>
<li class="40">
<span class="user"><strong>shin</strong></span>
<span class="msg"> delete me as well</span>
<span class="date">2010-01-14 16:01:44</span>
<a href="#" id="40" class="delete">x</a>
<div class="clear"></div></li>
...
...</ul>
Second part which is plain html
<ul id="another">
<li><a href="#">you can't delete me</a></li>
<li><a href="#" class="delete">delete this</a></li>
<li><a href="#" class="delete">delete this</a></li>
</ul>
JQuery와
나는 방법으로 CodeIgniter를 사용하고$(".delete").click(function(event) {
event.preventDefault();
loading.fadeIn();
var commentContainer = $(this).parent();
var id = $(this).attr("id");
// var string = 'id='+ id ;
$.ajax({
type: "POST",
url: "index.php/admin/messages/changestatus/"+id,
// data: string,
cache: false,
success: function(){
commentContainer.slideUp('slow', function() {$(this).remove();});
loading.fadeOut();
}
});
return false;
});
입니다.
아무런 오류도 발생시키지 않습니다. codeigniter에있는 다른 코드가 옳지 않은 것 같습니다. 당신의 도움을 주셔서 감사합니다. – shin