本文介绍了ASP.NET MVC ActionLink的jQuery中,模板TMPL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个jquery-TMPL定义的:
<脚本ID =postTemplate类型=文/ X-的jQuery-TMPL>
< DIV CLASS =DIV-MSG-行动-内>
@ Html.ActionLink(编辑,编辑,邮报,新{帖子ID =$ {}帖子ID},{新@class =按钮})
@ Html.ActionLink(回复,回复,邮报,新{topicId =$ {TopicId},新的{@class =按钮})
< / DIV>
< / SCRIPT>
操作链接结果中的$是连接coded到%24。有没有解决这个所以在我的动作链接的ID的方式将得到正确的更换?
解决方案
@ Html.ActionLink(编辑,编辑,邮报,新{=帖子ID999 },{新@class =后的按钮,})
@ Html.ActionLink(回复,回复,邮报,新{topicId =888},{新@class =回复按钮})...$(#postTemplate)文本($(#postTemplate)文本()代替(999,$ {}帖子ID));
$(#postTemplate)文本($(#postTemplate)文本()代替(888,$ {} TopicId));
这是我最后使用的解决方案。
I have a jquery-tmpl defined:
<script id="postTemplate" type="text/x-jquery-tmpl">
<div class="div-msg-actions-inner">
@Html.ActionLink("Edit", "Edit", "Post", new { postId = "${PostId}" }, new { @class = "button" })
@Html.ActionLink("Reply", "Reply", "Post", new { topicId = "${TopicId}" }, new { @class = "button" })
</div>
</script>
The action link results in the "$" being encoded into "%24". Is there a way around this so the ID in my action link will get replaced correctly?
解决方案
@Html.ActionLink("Edit", "Edit", "Post", new { postId = "999" }, new { @class = "post-button", })
@Html.ActionLink("Reply", "Reply", "Post", new { topicId = "888" }, new { @class = "reply-button" })
...
$("#postTemplate").text($("#postTemplate").text().replace("999", "${PostId}"));
$("#postTemplate").text($("#postTemplate").text().replace("888", "${TopicId}"));
This is the solution I ended up using.
这篇关于ASP.NET MVC ActionLink的jQuery中,模板TMPL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!