Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @using (Html.BeginForm())
- {
- <div id="editorRows">
- @foreach (var item in Model)
- {
- Html.RenderPartial("GiftEditorRow", item);
- }
- </div>
- @Html.ActionLink("Add another...", "BlankEditorRow", null, new { id = "addItem" })
- <input type="submit" value="Finished" />
- }
- @section Scripts {
- <script>
- $(document).ready(function () {
- $("#addItem").click(function () {
- $.ajax({
- url: this.href,
- cache: false,
- success: function (html) {
- $("#editorRows").append(html);
- }
- });
- return false;
- });
- $("a.deleteRow").on("click", function () {
- $(this).parents("div.editorRow:first").remove();
- return false;
- });
- });
- </script>
- }
- @model MvcApplication1.Models.Gift
- @using MvcApplication1.Helpers
- <div class="editorRow">
- @using (Html.BeginCollectionItem("gifts"))
- {
- <p>
- Item: @Html.TextBoxFor(x => x.Name)
- Value: @Html.TextBoxFor(x => x.Price, new { size = 4 })
- <a href="#" class="deleteRow">delete</a>
- </p>
- }
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement