2013-05-06 52 views
0

我正在使用AjaxResponse.Render()替換2個div,其中有2個與它們相關聯的部分視圖。如何使用AjaxResponse.Render()替換MVC中的跨度文本?

但也有像下面這樣的跨度:

<span id="total-counts">23 comments</span> 

我需要更換這個值也是如此。如何使用AjaxResponse.Render()來調用以替換此值?

此跨度沒有關聯視圖。這可能是一件容易的事,但我不能使它工作。

我試過這些:

注意第二個參數是視圖名稱。

AjaxResponse.Render("#total-counts", "string", comments.Count, UpdateStyle.Replace); 
AjaxResponse.Render("#total-counts", "", comments.Count, UpdateStyle.Replace); 

這些都不起作用。除非是唯一的方法,否則我不想創建局部視圖。

THX

回答

0

在阿賈克斯成功回調使用作爲

$("#total-counts").html(' '); 
$("#total-counts").html(comments.Count+" Comments"); 
+0

我不訪問計數的客戶端。 – kheya 2013-05-06 08:03:52