Class: Alchemy::Admin::ListFilter

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/alchemy/admin/list_filter.rb

Overview

Creates a live filter for lists of DOM items.

The items must have a html name attribute that holds the filterable value.

Example

Given a list of items:

<%= render Alchemy::Admin::ListFilter.new('#products .product') %>

<ul id="products">
  <li class="product" name="kat litter">Kat Litter</li>
  <li class="product" name="milk">Milk</li>
</ul>

Instance Method Summary collapse

Constructor Details

#initialize(items_selector, name_attribute: "name", placeholder: Alchemy.t(:filter), hotkey: nil) ⇒ ListFilter

Returns a new instance of ListFilter.



41
42
43
44
45
46
# File 'app/components/alchemy/admin/list_filter.rb', line 41

def initialize(items_selector, name_attribute: "name", placeholder: Alchemy.t(:filter), hotkey: nil)
  @items_selector = items_selector
  @name_attribute = name_attribute
  @placeholder = placeholder
  @hotkey = hotkey
end