0

ajax Code:

        $('.remove-item').click(function () {
                var iddata = $(this).attr("data");
                var confirmation = confirm("are you sure?");
                if (confirmation == true) {
                    $.ajax({
                        type: 'POST',
                        url: "@Url.Action("_Delete","Item")",
                        data: { Id: iddata },
                        ajaxasync: true,
                        success: function (data) {
                            alert(data);
                            $('.wrap').html(data);
                        },
                        error: function () {
                            alert("error");
                        }
                    });
                }
            });

Basically after first succesfull attempt to call this ajax, I'm refreshing/replacing partial view with (data) and when I try to delete item from list that is in data.. nothing is happening I don't know what info is neede yet for this.

Harugawa
  • 539
  • 5
  • 19
  • If the data your updating contains elements with `class="remove-item"`, and your want to handle the `.click()` event of those elements, then you need to use [event delegation](https://learn.jquery.com/events/event-delegation/) - `$(.wrap').on('click', .remove-item', function() { ....` –  Oct 11 '16 at 21:44
  • @StephenMuecke yeah, I tried it. IT ended up not launching at all even withing first try ;l – Harugawa Oct 11 '16 at 21:49
  • Then you have done something else wrong :) –  Oct 11 '16 at 21:50
  • also need to make sure that the `wrap` class example given is some element that actually exists in your html... can't use `$('.wrap')` if it doesn't match anything you have – charlietfl Oct 11 '16 at 21:54

0 Answers0