Advertisement
Guest User

Untitled

a guest
Sep 30th, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. @using (Html.BeginForm())
  2. {
  3. <div id="editorRows">
  4. @foreach (var item in Model)
  5. {
  6. Html.RenderPartial("GiftEditorRow", item);
  7. }
  8. </div>
  9. @Html.ActionLink("Add another...", "BlankEditorRow", null, new { id = "addItem" })
  10. <input type="submit" value="Finished" />
  11. }
  12.  
  13. @section Scripts {
  14. <script>
  15. $(document).ready(function () {
  16. $("#addItem").click(function () {
  17. $.ajax({
  18. url: this.href,
  19. cache: false,
  20. success: function (html) {
  21. $("#editorRows").append(html);
  22. }
  23. });
  24. return false;
  25. });
  26.  
  27. $("a.deleteRow").on("click", function () {
  28. $(this).parents("div.editorRow:first").remove();
  29. return false;
  30. });
  31. });
  32. </script>
  33. }
  34.  
  35. @model MvcApplication1.Models.Gift
  36. @using MvcApplication1.Helpers
  37.  
  38. <div class="editorRow">
  39. @using (Html.BeginCollectionItem("gifts"))
  40. {
  41. <p>
  42. Item: @Html.TextBoxFor(x => x.Name)
  43. Value: @Html.TextBoxFor(x => x.Price, new { size = 4 })
  44. <a href="#" class="deleteRow">delete</a>
  45. </p>
  46. }
  47. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement