Message ID | 20181001214252.14345-1-stephen@that.guru |
---|---|
State | Accepted |
Headers | show |
Series | templates: Avoid recursive call | expand |
On Mon, 2018-10-01 at 22:42 +0100, Stephen Finucane wrote: > We had registered an event handler on a checkbox in table header which > would call a function, 'checkboxes', on all checkboxes within that > table. This function, in turn, causes does its work and then triggers > event handlers for all modified checkboxes which include the original > table header checkbox. This resulted in the original event calling > itself recursively. > > Resolve this by only modifying the checkboxes in the table body. > > Signed-off-by: Stephen Finucane <stephen@that.guru> This is such an obvious fix that has been holding me back on some Bootstrap 4 work I'm doing. Applied straight away and backported, as noted below. Stephen > --- > This should be backported to stable/2.1. > --- > patchwork/templates/patchwork/partials/patch-list.html | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/patchwork/templates/patchwork/partials/patch-list.html b/patchwork/templates/patchwork/partials/patch-list.html > index 90cb7d78..4ba062ab 100644 > --- a/patchwork/templates/patchwork/partials/patch-list.html > +++ b/patchwork/templates/patchwork/partials/patch-list.html > @@ -41,9 +41,9 @@ $(document).ready(function() { > > $('#check-all').change(function(e) { > if(this.checked) { > - $('#patchlist').checkboxes('check'); > + $('#patchlist > tbody').checkboxes('check'); > } else { > - $('#patchlist').checkboxes('uncheck'); > + $('#patchlist > tbody').checkboxes('uncheck'); > } > e.preventDefault(); > });
diff --git a/patchwork/templates/patchwork/partials/patch-list.html b/patchwork/templates/patchwork/partials/patch-list.html index 90cb7d78..4ba062ab 100644 --- a/patchwork/templates/patchwork/partials/patch-list.html +++ b/patchwork/templates/patchwork/partials/patch-list.html @@ -41,9 +41,9 @@ $(document).ready(function() { $('#check-all').change(function(e) { if(this.checked) { - $('#patchlist').checkboxes('check'); + $('#patchlist > tbody').checkboxes('check'); } else { - $('#patchlist').checkboxes('uncheck'); + $('#patchlist > tbody').checkboxes('uncheck'); } e.preventDefault(); });
We had registered an event handler on a checkbox in table header which would call a function, 'checkboxes', on all checkboxes within that table. This function, in turn, causes does its work and then triggers event handlers for all modified checkboxes which include the original table header checkbox. This resulted in the original event calling itself recursively. Resolve this by only modifying the checkboxes in the table body. Signed-off-by: Stephen Finucane <stephen@that.guru> --- This should be backported to stable/2.1. --- patchwork/templates/patchwork/partials/patch-list.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)