GithubHelp home page GithubHelp logo

robertcasanova / jquery-selectbox Goto Github PK

View Code? Open in Web Editor NEW

This project forked from marcj/jquery-selectbox

1.0 1.0 0.0 133 KB

A jQuery plugin for replacing <select> elements.

Home Page: http://labs.abeautifulsite.net/projects/js/jquery/selectBox/

JavaScript 100.00%

jquery-selectbox's Introduction

jQuery selectBox: A styleable replacement for SELECT elements

Copyright 2011 Cory LaViska for A Beautiful Site, LLC. (http://www.abeautifulsite.net/)

Dual licensed under the MIT / GPLv2 licenses

IMPORTANT

I first started working on this plugin nearly two years ago, but I never ended up using it in production. Because of this, I can't prioritize further development for it and therefore the project is suffering.

If someone is interested in officially taking it over, please let me know.

For a more current, feature-rich plugin, consider using http://gregfranko.com/jquery.selectBoxIt.js/

Demo

http://labs.abeautifulsite.net/jquery-selectBox/

Features

  • Supports OPTGROUPS
  • Supports standard dropdown controls
  • Supports multi-select controls (i.e. multiple="multiple")
  • Supports inline controls (i.e. size="5")
  • Fully accessible via keyboard
  • Shift + click (or shift + enter) to select a range of options in multi-select controls
  • Type to search when the control has focus
  • Auto-height based on the size attribute (to use, omit the height property in your CSS!)
  • Tested in IE7-IE9, Firefox 3-4, recent WebKit browsers, and Opera

Usage

Link to the JS file:

<script src="jquery.selectbox.min.js" type="text/javascript"></script>

Add the CSS file (or append contents to your own stylesheet):

<link href="jquery.selectbox.min.css" rel="stylesheet" type="text/css" />

To create:

$("SELECT").selectBox([settings]);

Settings

To specify settings, use this syntax:

$("SELECT").selectBox('settings', { settingName: value, ... });

Available settings

  • menuTransition [default,slide,fade] - the show/hide transition for dropdown menus
  • menuSpeed [slow,normal,fast] - the show/hide transition speed
  • loopOptions [boolean] - flag to allow arrow keys to loop through options

Methods

To call a method use this syntax:

$("SELECT").selectBox('methodName', [options]);

Available methods

  • create - Creates the control (default)
  • destroy - Destroys the selectBox control and reverts back to the original form control
  • disable - Disables the control (i.e. disabled="disabled")
  • enable - Enables the control
  • value - if passed with a value, sets the control to that value; otherwise returns the current value
  • options - if passed either a string of HTML or a JSON object, replaces the existing options; otherwise returns the options container element as a jQuery object
  • control - returns the selectBox control element (an anchor tag) for working with directly
  • refresh - updates the selectBox control's options based on the original controls options

Events

Events are fired on the original select element. You can bind events like this:

$("SELECT").selectBox().change( function() { alert( $(this).val() ); } );

Available events

  • focus - Fired when the control gains focus
  • blur - Fired when the control loses focus
  • change - Fired when the value of a control changes
  • beforeopen - Fired before a dropdown menu opens (cancelable)
  • open - Fired after a dropdown menu opens (not cancelable)
  • beforeclose - Fired before a dropdown menu closes (cancelable)
  • close - Fired after a dropdown menu closes (not cancelable)

Known Issues

  • The blur and focus callbacks are not very reliable in IE7. The change callback works fine.

jquery-selectbox's People

Contributors

bastlynn avatar claviska avatar didip avatar flyingmana avatar linko avatar renaudleo avatar tomlion avatar wojtekzozlak avatar xjamundx avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.