zsharp
zsharp

Reputation: 13766

Returning a collection with Ajax Request

I have the following in my view:

 <ul id="statements">

    <% foreach (var s in Model.Statements)

    { %>
    <%Html.RenderPartial("StatementControl", s); %>

    <% } %>

</ul>

Now I want to use Ajax to return a new Statements object when user clicks on one of several links:

  <ul id="statementChoices">
    <li>group1<li>
    <li>group2<li>
    <li>group3<li>
  <ul>

If I use Ajax form how do I tell RenderPartial to render the new collection? How do I go about this? What about using JQUery here?

Upvotes: 0

Views: 228

Answers (1)

Jarrett Meyer
Jarrett Meyer

Reputation: 19593

Check out my blog. I've posted about this a few times.

http://www.jarrettmeyer.com/search?q=mvc

Generally, I'd wrap the whole thing that gets refreshed in a <div> and return a partial result from a controller.

Upvotes: 2

Related Questions