Reputation: 43
So i have this actionlink which will trigger action "gotoContent" which will return a partialVIew into some div in current page
<div id="itemColumn">
@Ajax.ActionLink("Go to content", "GotoContent", null, new AjaxOptions { HttpMethod = "GET", InsertionMode = InsertionMode.Replace, UpdateTargetId = "content" }, new { id = "item" })
</div>
So the problem is, this only triggered when we clicked right in the "Go to content" words, but what i need is, we can click everywhere on the whole div. It would be nice if anyone can help me with this.
Upvotes: 0
Views: 885
Reputation: 6809
To achieve what you are asking I think the right and easiest way to do it would be something like this:
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)
}
})
})
});
Upvotes: 1