Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"check all" boxes don't work in UI with Sidekiq 6.1.0 #4619

Closed
geoffharcourt opened this issue Jul 1, 2020 · 9 comments
Closed

"check all" boxes don't work in UI with Sidekiq 6.1.0 #4619

geoffharcourt opened this issue Jul 1, 2020 · 9 comments

Comments

@geoffharcourt
Copy link
Contributor

Ruby version:
Sidekiq / Pro / Enterprise version(s):

Sidekiq 6.1.0
Pro 5.1.0
Ent 2.1.0

The box to check all items in the list doesn't check all the items displayed on the Retries, Scheduled, or Dead pages after upgrading.

@mperham
Copy link
Collaborator

mperham commented Jul 1, 2020

I’d guess this is due to the jquery upgrade.

@mperham
Copy link
Collaborator

mperham commented Jul 1, 2020

I'm struggling to debug this issue since my JavaScript skills are sad but here's the code:

  $(document).on('click', '.check_all', function() {
    var checked = $(this).attr('checked');
    if (checked == 'checked') {
      $('input[type=checkbox]', $(this).closest('table')).attr('checked', checked);
    } else {
      $('input[type=checkbox]', $(this).closest('table')).removeAttr('checked');
    }
  });

and the HTML:

            <th class="table-checkbox checkbox-column">
              <label>
                <input type="checkbox" class="check_all" />
              </label>
            </th>

Anyone know why this wouldn't work in jQuery 1.12?

@jc00ke
Copy link
Contributor

jc00ke commented Jul 1, 2020

I'm just taking a stab here, but should 'input[type=checkbox]' be 'input[type="checkbox"]'?

@TheRusskiy
Copy link

@mperham it could be due to this change in 1.9:
https://jquery.com/upgrade-guide/1.9/#attr-versus-prop-
Essentially use prop instead of attr.

...
$(elem).prop("checked", true);
$(elem).prop("checked", false);
...

disclaimer: I haven't checked out the code and actually tried it

@mperham
Copy link
Collaborator

mperham commented Jul 1, 2020

  $(document).on('click', '.check_all', function() {
    var checked = $(this).attr('checked');
    if (checked == 'checked') {
      $('input[type=checkbox]', $(this).closest('table')).prop('checked', true);
    } else {
      $('input[type=checkbox]', $(this).closest('table')).prop('checked', false);
    }
  });

prop seems to have no effect.

@jc00ke
Copy link
Contributor

jc00ke commented Jul 1, 2020

With a later version of jQuery I would get undefined from .attr(). You can also get it as an boolean by using this.checked.

@mperham
Copy link
Collaborator

mperham commented Jul 1, 2020

@jc00ke Yer a wizard, Jesse! This works. Any reason why it wouldn't work on any modern browser?

$(document).on('click', '.check_all', function() {
    $('input[type=checkbox]', $(this).closest('table')).prop('checked', this.checked);
  });

@jc00ke
Copy link
Contributor

jc00ke commented Jul 1, 2020

I can't find any reasons. I'm pretty sure that's been around for a long time.

@mperham mperham closed this as completed in 214572e Jul 1, 2020
@mperham
Copy link
Collaborator

mperham commented Jul 1, 2020

@TheRusskiy @jc00ke Y'all are great, thank you for helping me fix the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants