Skip to content

stevepiron/jquery-select-to-list

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

jQuery select to list

A jQuery plugin turning selects into lists.

Default initialization

$('.js-select').spSelectToList();

Settings

Option Type Default Description
classes string 'js-created-list' The classes to be applied on the list, space-separated.
itemClasses string 'js-created-list__item' The classes to be applied on each list item, space-separated.
labelWrapTag string false The type of HTML element to wrap each label into (e.g. span).
labelWrapClasses string false The classes to be applied on the wrapping elements of the labels, if any.
attributesToKeep array [] An array of attributes already defined on the option elements to be applied on each list item as well.
selectFirstIfNone boolean false Sets the first list item as selected if no option is.
selectedClass string 'is-selected' The class applied to the selected list item.
onAfterInit function false A function to be executed before init.
onAfterSelect function false A function to be executed after selection.

Initialization with custom settings

$('.js-select').spSelectToList({
    classes: 'js-filter-list',
    itemClasses: 'js-filter-list__item',
    labelWrapTag: 'span',
    labelWrapClasses: 'js-filter-list__filter',
    attributesToKeep: ['data-count'],
    selectFirstIfNone: true,
    onAfterInit: function() {
        doSomething();
    }
});

Dependencies

jQuery

License

Copyright © Steve Piron

About

A jQuery plugin turning selects into lists.

Resources

Stars

Watchers

Forks

Packages

No packages published