2010-05-23 67 views
0

我無法弄清楚什麼是錯的。它的工作時,我試圖刷新只有主題,但它不起作用時,試圖刷新主題和頁面鏈接。即。主題表的清爽,'pagelinks'消失,我認爲純粹無法達到 - 閱讀第二個模板節點。順便說一句,我測試了他們的代碼,第一個消息框顯示了所有節點 - 包括'pagelinks'節點,但第二個 - 在函數中只顯示主題行。它看起來像一個錯誤。任何人都知道我怎麼解決這個問題?JQuery Pure Template

ps。我正在使用最新版本的純粹。

謝謝。

測試代碼 - pure.js線:189

function dataselectfn(sel) { 
    // ... 
    m = sel.split('.'); 
    alert(m.toSource()); 
    return function (ctxt) { 
     var data = ctxt.context; 
     if (!data) { 
      return ''; 
     } 

     alert('in function: ' + m.toSource()); 
     // ... 

JSON:

{"topics":[{"name":"foo"}],"pagelinks":[{"Page":1},{"Page":2}]} 

HTML - 前純粹的渲染:

<table> 
    <tbody> 
     <tr> 
      <td class="pagelinks"> 
       <a page="1" href="/Topics/IndexForAreas?page=1" class="p [email protected]">1</a> 
      </td> 

      <td class="pagelinks"> 
       <a page="2" href="/Topics/IndexForAreas?page=2" class="p [email protected]">2</a> 
      </td> 
     </tr> 
    </tbody> 
</table> 

HTML - 純渲染後:

<table> 
    <tbody> 
     <tr> 
     </tr> 
    </tbody> 
</table> 

控制器:

[Transaction] 
    public ActionResult IndexForAreas(int? page) 
    { 
     TopicService topicService = new TopicService(); 
     PagedList<Topic> topics = topicService.GetPaged(page); 
     if (Request.IsAjaxRequest()) 
     { 
      return Json(new { 
       topics = topics.Select(t => new { 
        name = t.Name, 
       }), 
       pagelinks = PagingHelper.AsPager(topics, 1) 
      }); 
     } 
     return View(topics); 
    } 

ASP.NET - 查看:

<div class="topiccontainer"> 
    <table> 
     <% 
      foreach (Topic topic in ViewData.Model) 
      { %> 
     <tr class="topics"> 
      <td> 
       <%= Html.ActionLink<ForumPostsController>(ec => ec.Index(topic.Name, null), topic.Name, new { @class="name [email protected]" })%> 
      </td> 
      //bla bla... 
     </tr> 
     <%} %> 
    </table> 
    <table> 
     <tr> 
      <% Html.Pager(Model, 1, p => 
      { %> 
      <td class="pagelinks"> 
       <%= Html.ActionLink<TopicsController>(c => c.IndexForAreas(p.Page), p.Page.ToString(), new { page = p.Page, @class = "[email protected]" })%> 
      </td> 
      <% }); %> 
     </tr> 
    </table> 
</div> 

母版頁:

<% Html.RenderAction("IndexForAreas", "Topics", new { area = "" }); %> 
    <script type="text/javascript"> 
     $.post("<%= Html.BuildUrlFromExpressionForAreas<TopicsController>(c => c.IndexForAreas(null)) %>", { page: page }, 
       function (data) { 
        $(".topiccontainer").autoRender(data); 
       }, 
       "json" 
     ); 
    </script> 

回答