When you click on 'Select All' button it actually selects all the items in the list only the first time. I found that the problem is in entity_reference_view_widget.js file:

if ($(this).data('unselect')) {
       $(checkboxes).removeAttr('checked');
       $(this).data('unselect', 0).text(Drupal.t('Select all'));
}
else {
       $(checkboxes).attr('checked', 'checked');
       $(this).data('unselect', 1).text(Drupal.t('Unselect all'));
}

I managed to fix it on my project by replacing removeAttr and attr functions with the prop function using false and true respectively.

if ($(this).data('unselect')) {
       $(checkboxes).prop('checked',false);
       $(this).data('unselect', 0).text(Drupal.t('Select all'));
}
else {
       $(checkboxes).prop('checked',true);
       $(this).data('unselect', 1).text(Drupal.t('Unselect all'));
}
CommentFileSizeAuthor
#3 select_all-2530020-3.patch1.15 KBplopesc

Comments

lmouzos’s picture

Issue summary: View changes
jsacksick’s picture

Unfortunately, we can't use prop() because it has been added in Jquery 1.6 and Drupal 7 only ships with jQuery v1.4.4.

plopesc’s picture

Status: Active » Needs review
StatusFileSize
new1.15 KB

Hello,

I'm having this problem too, but in my case, I'm using JQuery Update module, so my JQuery version is higher than 1.6, where prop() method was added.

Here I'm proposing a patch that checks the JQuery version and in case version in lower than 1.6, fallbacks to use attr() instead of prop().

Hope this helps!

Thank you again for this great module :)

carolpettirossi’s picture

#3 works for me.

fran seva’s picture

Status: Needs review » Reviewed & tested by the community

I have reviewed the code and looks good. The way the version is checked is correct so let's move it to RTBC

  • jsacksick committed 13defff on 7.x-2.x authored by plopesc
    Issue #2530020 by plopesc: Fix 'Select All' button works only once
    
jsacksick’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jamsilver’s picture

As far as I can tell, the fix here broke the 'Select all' link - see #2771281: The "Select all" link does not work