MVC 4 Ajax does not update the partial view in the page

advertisements

I'm doing a site using MVC 4. It's a site that list musics and the user can create a playlist (like a cart shopping).

I have for every music this action link that should be executed in Ajax:

@Ajax.ActionLink("Adicionar à Playlist","AddPlaylist", new { id = item.MusicaID }, new AjaxOptions {UpdateTargetId="playlist", InsertionMode=InsertionMode.Replace})

The action method from the controller returns a PartialView (the cart of playlist) and only that should update but instead of getting the whole page with that part updated I get a partial view and nothing more on the page.

This is the part where I render the PartialView:

<section id="playlist">
     @Html.Partial("_PlaylistPartial")
</section>

Shouldn't this work like I have?


Make sure you have included

<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>

in your view