2010-06-06 2 views
0

내 웹 페이지에 다음 호출을 만드는 중이라서 :이 다른 코드는하지만컨트롤러에서 부분 뷰를 반환 할 때 jQuery를 다시로드 하시겠습니까?

<div id="comments"> 
    <fieldset> 
      <h4> 
       Post your comment</h4> 
      <% using (this.Ajax.BeginForm("CreateStoryComment", "Story", new { id = story.StoryId }, new AjaxOptions { UpdateTargetId = "comments", OnSuccess = "OnStoryCommentAdded" })) 
       { %> 
      <%= this.Html.TextArea("Body", string.Empty)%> 
      <input type="submit" value="Add Comment" /> 
      <% } %> 
    </fieldset> 
</div> 

즉 그것의 요점입니다. 컨트롤러는 주석 div에있는 모든 것을 "새로 고침"하는 부분 뷰를 반환합니다.

내 문제는 다음과 같은 jQuery를 적용하지 않을 것입니다 :

$(".comment .delete").click(function() { 
    if (confirm("Are you sure you want to delete this record?") == true) { 
     $.post(this.href); 
     $(this).parents(".comment").fadeOut("normal"); 
    } 
    return false; 
}); 

내가 있으리라 믿고있어이를 첨부하지 않을 것 때문에 inital 페이지로드 후 jQuery를로드합니다. 내 가정이 맞다면이 jQuery를 "새로 고침"하는 방법

바라건대 그게 말이 되네요! :)

답변

2

.live 키워드를 사용하면 문서 내에서 요소를 만들 때 요소에 코드를 연결할 수 있습니다.

+0

완벽하게 작동했습니다. 고맙습니다! – mattruma

관련 문제