JQuery 纯模板
我不知道出了什么问题。当我尝试仅刷新主题时它起作用,但当尝试刷新主题和页面链接时它不起作用。 IE。主题表刷新,“页面链接”消失,我认为纯粹无法到达 - 读取第二个模板节点。
顺便说一句,我测试了他们的代码,第一个消息框显示所有节点 - 包括“页面链接”节点,但第二个消息框 - 在函数中仅显示主题行。它看起来像一个错误。有人知道我该如何解决这个问题吗?
附注我用的是最新版本的pure.
谢谢。
测试代码 - 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 Page@page">1</a>
</td>
<td class="pagelinks">
<a page="2" href="/Topics/IndexForAreas?page=2" class="p Page@page">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 viewlink@href" })%>
</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 = "Page@page" })%>
</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>
I cant figure out whats wrong. Its working when i tried to refresh only topics but it doesnt works when tried to refresh topics and page-links. ie. topics table's refreshing, and 'pagelinks' disappearing, i thought pure cannot reach - read second template node.
By the way, i tested their code, first message box show up all of nodes - includes 'pagelinks' node, but second one - in function only show up topic rows. Its look like a bug. Anyone knows how can i solve this?
ps. I'm using latest version of pure.
Thanks.
Test Code - pure.js line: 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 - before pure rendering:
<table>
<tbody>
<tr>
<td class="pagelinks">
<a page="1" href="/Topics/IndexForAreas?page=1" class="p Page@page">1</a>
</td>
<td class="pagelinks">
<a page="2" href="/Topics/IndexForAreas?page=2" class="p Page@page">2</a>
</td>
</tr>
</tbody>
</table>
HTML - after pure rendering:
<table>
<tbody>
<tr>
</tr>
</tbody>
</table>
Controller:
[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 - View:
<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 viewlink@href" })%>
</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 = "Page@page" })%>
</td>
<% }); %>
</tr>
</table>
</div>
Master Page:
<% 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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下次您对 PURE 有任何疑问或问题时,可以将其发布到:http ://groups.google.com/group/Pure-Unobtrusive-Rendering-Engine
一般来说,您会在那里得到快速响应。
Next time you have a question or a problem about PURE you can post it at: http://groups.google.com/group/Pure-Unobtrusive-Rendering-Engine
In general, you'll get a fast response there.