Skip to content
This repository has been archived by the owner on Nov 29, 2022. It is now read-only.

Latest commit

 

History

History
42 lines (38 loc) · 1.09 KB

README.md

File metadata and controls

42 lines (38 loc) · 1.09 KB

jQuery-UI-reduceOptions-Plugin

Simple jQuery UI plugin that acts on grouped elements and allows hiding of unselected ones, toggle included. You can see a working example at https://www.port-of-art.com in the filter section in the left sidebar.

Usage

// prepare options for select option reduction
var options = {
  element_inner: 'input[type=checkbox]',
  element_outer: '.form-item',
  attribute: 'checked',
  value: 'checked',
  label_more: 'show all',
  label_less: 'show less',
  observe: 'ajaxSuccess',
  show: function(el) {
    $(el).fadeIn('slow');
  },
  hide: function(el) {
    $(el).hide();
  }
};
$('#element-id').reduceOptions(options);

This would work on markup like the following:

<div id="element-id">
  <div class="form-item">
    <input type="checkbox" name="mycheckbox_1" value="1" />
  </div>
  <div class="form-item">
    <input type="checkbox" name="mycheckbox_2" value="2" />
  </div>
  <div class="form-item">
    <input type="checkbox" name="mycheckbox_3" value="3" />
  </div>
</div>