Navigation
MavSelectBox v0.5.5 (A mootools more library)
MavSelectBox is a simple-to-use form select replacement that allows for better customization. I had the need for this myself and all though there are a few out there that do a damn good job, none were exactly what i felt i needed. And as we all know, competition breeds innovation, right?
MavSelectBox mimics the GUI interactions of a normal select element as much as possible (the non-annoying anyway). This is done so as not to break with user expectations. Up and down arrows move the selection, tabbing to it and hitting alt+down shows the menu, tabbing to it and simply hitting up or down selects the next available option in that direction, focusing then start typing and the option that matches what you are typing is selected, enter selects, esc closes, and so on.
Discussion
For now, all discussion will be located at the unofficial mootools forum. Partly because i think people will probably look there for it anyway, partly i hate setting up forums, and also because right now i'm feeling lazy. ^_^
Discuss MavSelectBox on the unofficial mootools forumDownload MavSelectBox
MavSelectBox requires the mootools core framework v1.2+. You can play around with customizing it if you want, but i would recommend just grabbing the
default core. I will post a barebone requirement if so desired.
You will need two parts for MavSelectBox to work correctly; both a Javascript library, and a CSS file. The CSS provided below contains just the basic classes (and default class names) required for MavSelectBox to function.
You can of course specify your own attributes, styles, and class names. If you chose to change the class names, be sure to specify them in the options as seen below in the example and option layout.
Get the newest Mootools Core MavSelectBox Basic CSS file MavSelectBox Javascript (uncompressed)
Back to topExamples
Usage
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="/path/to/css/mavselectbox.css" />
<script type="text/javascript" src="/path/to/js/mootools.core.js"></script>
<script type="text/javascript" src="/path/to/js/class.MavSelectBox.js"></script>
<script type="text/javascript">
window.addEvent('domready', function() {
var my_select = new MavSelectBox('select_field');
});
</script>
</head>
<body>
<select id="select_field" class="some_class" style="width:200px">
<option value="first" class="bland">First option</option>
<option value="second" style="color:red">Second-best option</option>
<optgroup label="Optgroups are hip">
<option value="opty" class="optful">First optgroup option</option>
<option value="" disabled="disabled">I be disabled option!</option>
</optgroup>
<option value="thirdee" selected="selected">Selected third!</option>
<option value="lastestes" class="bright sweet" >lastest and Bestest</option>
</select>
</body>
</html>
Back to top
Syntax
// Simplest method possible
var my_select = new MavSelectBox('element_id');
// Specify an onSelect method and alternate option colors
var your_select = new MavSelectBox({
elem: $('another_id'),
alternate: true,
onSelect: function(_elem) {
// Do somethin' funky!
}
});
Back to top
Arguments
-
The element to be replaced or options to be set
(Element)
The element will be extended if it is not already.(String)
A string containing the id of the DOM element.(Object)
An object containing the element and additional options.
Returns
(Element)
A MavSelectBox element.(null)
Null if an error occurred, or if no element specified.
Options
Back to topCompatibility
Tested and working with:- Firefox 2 / Firefox 3
- IE 7, IE 8 (not sure about IE 6... don't really care.)
- Opera 9.63
- Google Chrome 1.0.154.36
- Safari 3.2.1
Changelog
-
v 0.5.5 - June 9th, 2009
- IE Scrolling bug fix. Contributed by Quentin Ambard
- RemoveEvents modifications. Contributed by Quentin Ambard
-
v 0.5.1 - April 26th, 2009
- Real bug fix for multi-select bug! Contributed by Quentin Ambard
-
v 0.5.0 - April 26th, 2009
- Added container code contributed by Quentin Ambard
- Multi-select bug fix. (Temp for now)
-
v 0.4.9 - April 26th, 2009
- Fixed issue with webkit browsers where menu would not close after option was selected
- Official release with nearly all desired functionality working, and only a few bug fixes to make