Skip to content

Commit 657c456

Browse files
committed
Initial release v1.0.0 - jQuery multiselect dropdown plugin
0 parents  commit 657c456

File tree

9 files changed

+1514
-0
lines changed

9 files changed

+1514
-0
lines changed

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Ignore node_modules if added later
2+
node_modules/
3+
4+
# OS files
5+
.DS_Store
6+
Thumbs.db
7+
8+
# IDE files
9+
.idea/
10+
.vscode/
11+
*.swp
12+
*.swo
13+
14+
# Logs
15+
*.log

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 fungus007
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
# InterActiveMultiSelect
2+
3+
A jQuery multiselect dropdown plugin I built for my projects. Supports checkboxes, radio buttons, search, and works great with Bootstrap modals.
4+
5+
![Demo](https://img.shields.io/badge/jQuery-Plugin-blue) ![License](https://img.shields.io/badge/license-MIT-green)
6+
7+
## Why I Made This
8+
9+
I needed a simple multiselect that:
10+
- Shows selected items as tags (like select2 but lighter)
11+
- Works inside Bootstrap modals without breaking
12+
- Plays nice with ASP.NET MVC forms
13+
- Doesn't need a ton of dependencies
14+
15+
So I built one.
16+
17+
## Quick Start
18+
19+
**1. Include the files**
20+
21+
```html
22+
<link href="css/InterActiveMultiSelect.css" rel="stylesheet">
23+
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
24+
<script src="js/InterActiveMultiSelect.js"></script>
25+
```
26+
27+
**2. Create a select**
28+
29+
```html
30+
<select id="mySelect" name="items" multiple>
31+
<option value="1">Option 1</option>
32+
<option value="2">Option 2</option>
33+
<option value="3">Option 3</option>
34+
</select>
35+
```
36+
37+
**3. Initialize**
38+
39+
```javascript
40+
$('#mySelect').interActiveMultiSelect();
41+
```
42+
43+
That's it.
44+
45+
## Options
46+
47+
```javascript
48+
$('#mySelect').interActiveMultiSelect({
49+
mode: 'checkbox', // 'checkbox' or 'radio'
50+
placeholder: 'Select...',
51+
search: true, // adds search box
52+
searchPlaceholder: 'Type to search...',
53+
selectAllText: 'Select All',
54+
clearText: 'Clear'
55+
});
56+
```
57+
58+
| Option | Default | What it does |
59+
|--------|---------|--------------|
60+
| mode | 'checkbox' | Use 'radio' for single select |
61+
| placeholder | 'Select' | Text shown when nothing selected |
62+
| search | false | Adds a search/filter box |
63+
| searchPlaceholder | 'Search...' | Placeholder for search input |
64+
65+
## With Search
66+
67+
```javascript
68+
$('#employees').interActiveMultiSelect({
69+
search: true,
70+
placeholder: 'Pick employees'
71+
});
72+
```
73+
74+
## Radio Mode (Single Select)
75+
76+
```javascript
77+
$('#country').interActiveMultiSelect({
78+
mode: 'radio',
79+
placeholder: 'Choose country'
80+
});
81+
```
82+
83+
## Pre-selected Values
84+
85+
Just add `selected` to your options:
86+
87+
```html
88+
<select id="cats" multiple>
89+
<option value="1" selected>Already picked</option>
90+
<option value="2">Not picked</option>
91+
<option value="3" selected>Also picked</option>
92+
</select>
93+
```
94+
95+
Works great for edit forms.
96+
97+
## ASP.NET MVC
98+
99+
Standard Razor stuff:
100+
101+
```html
102+
<select id="categories" name="CategoryIds" multiple>
103+
@foreach(var c in Model.Categories)
104+
{
105+
<option value="@c.Id" @(Model.Selected.Contains(c.Id) ? "selected" : "")>
106+
@c.Name
107+
</option>
108+
}
109+
</select>
110+
111+
<script>
112+
$(function(){
113+
$('#categories').interActiveMultiSelect();
114+
});
115+
</script>
116+
```
117+
118+
Controller gets the values as `int[] CategoryIds` - nothing special needed.
119+
120+
## Inside Bootstrap Modals
121+
122+
Initialize when modal opens:
123+
124+
```javascript
125+
$('#myModal').on('shown.bs.modal', function(){
126+
$('#modalSelect').interActiveMultiSelect();
127+
});
128+
```
129+
130+
## Customizing Colors
131+
132+
Override CSS variables:
133+
134+
```css
135+
:root {
136+
--ias-tag-bg: #28a745; /* tag background */
137+
--ias-tag-color: #fff; /* tag text */
138+
--ias-focus-border: #28a745; /* focus ring */
139+
--ias-item-selected-bg: #d4edda; /* selected row bg */
140+
--ias-checkbox-color: #28a745; /* checkbox color */
141+
}
142+
```
143+
144+
Or scope to specific element:
145+
146+
```css
147+
#mySelect + .ias-wrapper {
148+
--ias-tag-bg: #dc3545;
149+
}
150+
```
151+
152+
### All CSS Variables
153+
154+
```css
155+
/* Button */
156+
--ias-btn-bg: #fff;
157+
--ias-btn-border: #ced4da;
158+
--ias-btn-color: #212529;
159+
--ias-btn-radius: 0.375rem;
160+
--ias-btn-min-height: 38px;
161+
162+
/* Focus glow */
163+
--ias-focus-border: #0d6efd;
164+
--ias-focus-glow: rgba(13, 110, 253, 0.35);
165+
166+
/* Tags */
167+
--ias-tag-bg: #0d6efd;
168+
--ias-tag-color: #fff;
169+
--ias-tag-radius: 0.25rem;
170+
171+
/* Dropdown */
172+
--ias-dropdown-bg: #fff;
173+
--ias-dropdown-border: #ced4da;
174+
--ias-dropdown-shadow: 0 0.5rem 1rem rgba(0,0,0,0.15);
175+
176+
/* List items */
177+
--ias-item-color: #212529;
178+
--ias-item-hover-bg: #f8f9fa;
179+
--ias-item-selected-bg: #cfe2ff;
180+
--ias-item-selected-color: #084298;
181+
182+
/* Checkbox */
183+
--ias-checkbox-color: #0d6efd;
184+
--ias-checkbox-size: 1rem;
185+
186+
/* Other */
187+
--ias-placeholder-color: #6c757d;
188+
--ias-arrow-color: #6c757d;
189+
--ias-select-all-color: #198754;
190+
--ias-clear-color: #dc3545;
191+
```
192+
193+
## Get Selected Values
194+
195+
```javascript
196+
// array of values
197+
var vals = $('#mySelect').val();
198+
199+
// listen for changes
200+
$('#mySelect').on('change', function(){
201+
console.log($(this).val());
202+
});
203+
```
204+
205+
## Methods
206+
207+
```javascript
208+
// destroy and restore original select
209+
$('#mySelect').interActiveMultiSelect('destroy');
210+
211+
// rebuild (useful after adding options dynamically)
212+
$('#mySelect').interActiveMultiSelect('refresh');
213+
```
214+
215+
## Disabled Options
216+
217+
```html
218+
<option value="2" disabled>Can't select this</option>
219+
```
220+
221+
## Troubleshooting
222+
223+
### Dropdown gets cut off in modal
224+
225+
Your modal CSS probably has `overflow: hidden`. Fix:
226+
227+
```css
228+
.modal .your-card-class {
229+
overflow: visible !important;
230+
}
231+
```
232+
233+
### Not working?
234+
235+
1. Make sure jQuery is loaded before the plugin
236+
2. Check console for errors
237+
3. Make sure select has `multiple` attribute for checkbox mode
238+
239+
## Files
240+
241+
```
242+
├── css/
243+
│ ├── InterActiveMultiSelect.css (dev)
244+
│ └── InterActiveMultiSelect.min.css (prod, ~4kb)
245+
├── js/
246+
│ ├── InterActiveMultiSelect.js (dev)
247+
│ └── InterActiveMultiSelect.min.js (prod, ~8kb)
248+
└── index.html (demo)
249+
```
250+
251+
## Browser Support
252+
253+
Chrome, Firefox, Safari, Edge. Should work in IE11 too but I haven't tested much.
254+
255+
## License
256+
257+
MIT - do whatever you want with it.
258+
259+
---
260+
261+
Made by **fungus007**

0 commit comments

Comments
 (0)