Skip to content

Select multiple data or single by using a modal. It has the options such as search and filter based on parent category

Notifications You must be signed in to change notification settings

Abilash-Abi/js-multilevel-searchable-modal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

js-multilevel-searchable-modal

Multiple

https://github.com/Abilash-Abi/js-multilevel-searchable-modal/blob/2022e08549a31b381b4488b378512ba83adb7f92/demo/checkbox.png https://github.com/Abilash-Abi/js-multilevel-searchable-modal/blob/2022e08549a31b381b4488b378512ba83adb7f92/demo/selected-checkbox.png

Single

https://github.com/Abilash-Abi/js-multilevel-searchable-modal/blob/2022e08549a31b381b4488b378512ba83adb7f92/demo/single-select.png

https://github.com/Abilash-Abi/js-multilevel-searchable-modal/blob/2022e08549a31b381b4488b378512ba83adb7f92/demo/singleselected.png

Installation

Download or clone this repo and run index.html

Usage

let data = [
	{
		name:"Beauty & Toys",
		id:1,
		childs:[]
	}
]
$('#searchable').searchable(data,[]);
#selected - selected checkbox ids, eg [1,2]
#options - SearchableCheckbox configuration properties
<html>
<head>
    <link rel="stylesheet" href="./lib//searchable-checkbox.css" />
</head>
<body>
          <input type="text" id="searchable" class="input-field" />
</body>
<script src="./lib/searchable-checkbox.js"></script>
<script>
       $('#searchable').searchable(data,[]);

	</script>
</html>

Advanced Setup

 $('#searchable').searchable(data,[],{
        chip:false,
        renderFooter:(closeBtnId,doneBtnId)=>{return '<button id="'+doneBtnId+'">Done</button>'},
                  renderCheckbox:(item,selected,className,id)=>{
                let checked = selected ? 'checked' : '';
                return '<input id='+id+' type="checkbox" '+checked+' value="'+item.id+'" class="'+className+'">'+item.name;
            },

            renderHeader:(searchInputId)=>{
                return '<h3>Categories<h3><input type="text" id="'+searchInputId+'" placeholder="Search Category    "/>';
            }
    });

Options

Name Type Default Note
chip bool true If set false, then parent chip will not show
type string checkbox Pass 'radio' for single select
renderFooter(closeBtnId,doneBtnId) Function default Enable you to render custom footer for modal
renderCheckbox(item,selected,className) Function default Enable you to render custom checkbox and logic
renderHeader(searchInputId) Function default Custom header for modal with search input feature

About

Select multiple data or single by using a modal. It has the options such as search and filter based on parent category

Topics

Resources

Stars

Watchers

Forks