所以我有这个actionlink会触发动作“gotoContent”,它会将partialVIew返回到当前页面的某个div中
<div id="itemColumn">
@Ajax.ActionLink("Go to content", "GotoContent", null, new AjaxOptions { HttpMethod = "GET", InsertionMode = InsertionMode.Replace, UpdateTargetId = "content" }, new { id = "item" })
</div>
所以问题是,这只是在我们点击“转到内容”字样时触发,但我需要的是,我们可以点击整个div的所有地方。如果有人能帮助我,那就太好了。
答案 0 :(得分:1)
要实现你所要求的,我认为正确和最简单的方法就是这样:
HTML:
<div id="itemColumn">
// put whatever text you want the Div to Contain but don't make it an action link. We will handle this in Jquery by essentially making your div an action link.
</div>
使用Javascript:
$(function(){
$('#itemColumn').click(function(){
$.ajax({
url: '@Url.Action("GotoContent", "ControllerName")',
type: "GET",
success: function(result) {
$('#content').html(result); // this will update your target div with the result (your partial view)
}
})
})
});