Mike
Mike

Reputation: 2339

refresh partial popup with new data

I have a partial that displays a table and has backend pagination. The pagination looks like:

@Ajax.ActionLink(">>", "EventHistory", "Event", new { id = ViewBag.EventId, page = ViewBag.Page+1 }, new AjaxOptions { HttpMethod = "GET" })

which calls:

public ActionResult EventHistory(int id, int page = 1)
    {
        var viewModel = eventService.GetHistory(id, page);
        ViewBag.EventId = id;
        ViewBag.Page = page;
        return PartialView("History", viewModel);
    }

When debugging I can see that the viewModel has the proper data in it, but the partial popup does not update with the new data. How can I refresh or update the partial with the correct data.

Upvotes: 0

Views: 92

Answers (1)

Satpal
Satpal

Reputation: 133453

You need to set AjaxOptions properties

new AjaxOptions { 
   HttpMethod = "GET", 
   InsertionMode = "Replace", // the mode that specifies how to insert the response into the target DOM element.
   UpdateTargetId = "ContainerId", //sets the ID of the DOM element to update by using the response from the server
}

Upvotes: 1

Related Questions