This is a UI enhancement for long lists of terms. Here is the jQuery to accomplish this (add within Drupal.behaviors.initBetterSelect):

  // Scroll to first checked term
  $(".better-select div.form-checkboxes-scroll").each(function(i) {
    $this = $(this);   
    $(this).animate({
      scrollTop: $this.find("input:checked").offset().top - $this.offset().top - $this.height() / 2
    })    
  });

Comments

Jonah Ellison’s picture

Oops, change $(this).animate to $this.animate

Jonah Ellison’s picture

JS error fix and remove animate delay:

// Scroll to first checked term
$(".better-select div.form-checkboxes-scroll").each(function(i) {
  $this = $(this);
  $checked = $this.find("input:checked");       
  if($checked.length) {
    $this.animate({
      scrollTop: $checked.offset().top - $this.offset().top - $this.height() / 2
    }, 1);
  }   
});
john franklin’s picture

Status: Active » Fixed

I took your jQuery and made it optional. You need to enable 'Scroll to the first selected item' in the Better Select preferences to enable it.

Thanks for the patch.

Status: Fixed » Closed (fixed)

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