2011-04-05 3 views
0

내 사이트에 댓글을 게시 할 수있는 권한이 있습니다. 사용자는 필드 히트 "게시"를 입력하고 난에 코멘트를 표시 JQuery와 템플릿을 사용 HTML 인코딩 된 Json 객체 (MVC에서 Jquery 템플릿 사용)

public ActionResult PostComment(Comment NewComment) 
    { 
     var repository = GetRepository<Comment>(); 
     var player = GetPlayer(); 
     //we have this stuff 
     NewComment.Created = DateTime.Now; 
     NewComment.Updated = NewComment.Created; 
     NewComment.Live = true; 
     NewComment.Player = player; 

     repository.Add(NewComment); 

     return new JsonResult { Data = new { Success = true, Comment = new CommentSummary(NewComment, player) } }; 
    } 

는 내 JQuery와에 reuturned되는이 작업 결과에 처리되어 데이터베이스에 다시 주석을 아약스 어떤 사용자가 아래로 다시 게시 할 때
로 변환됩니다 들어간 입력하지만, JQuery와 템플릿 단지 일부가되는 대신 전체보기 페이지에 그들을두고 나는이 HTML 인코딩 문제가 있어요 어떤 이유로 페이지

$.post("/comments/PostComment", data, function(json) { 
     if(json.Success){    
      var newComment = [ 
       { 
       Id: json.Comment.id, 
       postedOn: json.Comment.postedOn, 
       postedBy: json.Comment.postedBy, 
       body: json.Comment.body 
       } 
      ]; 

      /* Compile markup string as a named template */ 
      $.template("TmplComment", $("#CommentTemplate").html()); 

      /* Render the named template */ 
      $.tmpl("TmplComment", newComment).prependTo("#AllComments"); 

      //Do some tidying 
      $('#Comments_HasComments').show(); 
      $('#Comments_HasNoComments').hide(); 
      $("#frmPostComment textarea[name='comment']").val('') 

      //go to your comment 
      $("#Comment_" + json.Comment.id).animate({backgroundColor: "#F4FF8C"}, 1000).animate({backgroundColor: "#ffffff"}, 1000); 
      location.href = "#Comment_" + json.Comment.id; 
     }       
    }); 

코드의

내가 켜고 끌 필요가있는 것이 무엇입니까 ??

답변

1

의견 본문에 {{html}} template tag을 사용하고 있습니까?

+0

완벽한 당신은 내 jquery 템플릿 물건 덕분에 내 눈을 뜨게 해 주셔서 감사합니다 !! – Steve