question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Delete confirmation triggered twice in an inner repeater

See original GitHub issue

My JS looks like this:

    $('.out_repeater').repeater({
        show: function () {
            $(this).slideDown();
        },
        hide: function (deleteElement) {
            if (confirm('Are you sure you want to delete this element?')) {
                $(this).slideUp(deleteElement);
            }
        },
        isFirstItemUndeletable: true,
        repeaters: [{
            selector: '.in_repeater',
            show: function () {
                $(this).slideDown();
            },
            hide: function (deleteElement) {
                if (confirm('Are you sure you want to delete this element?')) {
                    $(this).slideUp(deleteElement);
                }
            }
        }]
    });

For some reason when the delete button for an item inside the “in_repeater”, it triggers the “Are you sure” confirmation twice.

Everything else works fine!

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery.repeater/1.2.1/jquery.repeater.min.js"></script>

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
AbhishekGandhi7commented, Jul 18, 2021

$list.on(‘click’, ‘[data-repeater-delete]’, function(event) { event.stopImmediatePropagation(); // add this, It works for me perfectly // event.stopPropagation(); var self = $(this).closest(‘[data-repeater-item]’).get(0); hide.call(self, function() { $(self).remove(); setIndexes($items(), getGroupName(), fig.repeaters); }); });

Thanks @martinmurciego it’s save my day.

1reaction
martinmurciegocommented, Nov 22, 2018

Please, give a more detailed example in jsfiddle or codepen about eliminating nested repeaters, since I have this same problem. As I must respond with a different behavior to the slideUp and slideDown of each repeater I need to be able to identify each one: https://github.com/DubFriend/jquery.repeater/issues/98#issue-383246502 Some alternative or it will be that the developer can update this suggested change in a new version.

$list.on('click', '[data-repeater-delete]', function(event) {
event.stopPropagation(); // added this
var self = $(this).closest('[data-repeater-item]').get(0);
hide.call(self, function() {
$(self).remove();
setIndexes($items(), getGroupName(), fig.repeaters);
});
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Ruby on Rails : Delete confirmation pop-up dialog displaying ...
When I click on "Delete Campaign" link, I am getting confirmation pop-up twice. This is happening on client's production environment only. Using Ruby...
Read more >
Nested repeater performance issue. Item events being called ...
"The repeater calls databind on all its item children in the ItemDataBound event. So the inner repeater is databound once by the outer...
Read more >
Gravity Forms Nested Forms | Gravity Forms Repeater Add-on
Gravity Forms Nested Forms also works as a Gravity Forms Repeater! ... Child entries can be edited by clicking Edit and deleted by...
Read more >
how to get repeater's button id for updatepanel triggers
Hi guys, i have a button in a repeater with update panel. now, the problem is, the triggers controlID is not able get...
Read more >
frm_validate_field_entry - Formidable Forms
The Pro validation will remove any error messages for fields that are ... 31 to the ID of the confirmation field (second field)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found