views:

50

answers:

1

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?

+2  A: 

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.

Jarrett Meyer
thats fine, but what about looping through the collection with the foreach? Can it be done?
zsharp
Yes, because you're returning the rendered partial view result.
Jarrett Meyer