我在我的页面上有多个DIV,而且我在使用另一个页面视图填充正确的DIV时遇到了问题。我会很感激一些帮助。用另一个页面内容动态填充正确的DIV
我有一个循环,填充DIV列表。最终解析HTML看起来是这样的:
<div id="replycontainer:1">
CONTENT1
<button id="to:1" class="reply">REPLY</button>
</div>
<div id="replycontainer:2">
CONTENT2
<button id="to:2" class="reply">REPLY</button>
</div>
<div id="replycontainer:3">
CONTENT3
<button id="to:3" class="reply">REPLY</button>
</div>
现在让我们说一个用户点击了一个按钮“:3”,现在我需要添加一个“注释”框“#replycontainer:3”。
我认为是正确的JavaScript不起作用。它正确地检测点击的DIV类,但是没有其他页面内容被添加到选定的DIV中。
可能是什么问题?
使用Javascript/jQuery的我用它来检测点击了哪个按钮DIV:
<script type="text/javascript">
$(document).ready(function() {
$("button.reply").click(loadComment);
});
function loadComment() {
var id = this.id.split('to:');
var postId = id[1];
var containername = "#replycontainer:" + postId;
$(containername).load("/Post/Comment"); //MVC Action pointer
}
</script>
提前感谢!
就是这样。谢谢 – Shenaniganz 2012-02-27 00:50:06