*These fields are required.
FlexBox CodePlex Project Page
FlexBox jQuery Plugin Page
Take Me To FlexBox Demos!
FlexBox is a jQuery plugin that is intended to be a very flexible replacement for html
textboxes and dropdowns, optionally using ajax to retrieve and bind JSON data.
It can be used as a:
It supports:
Please visit the CodePlex Project Page to download FlexBox
Here is a teaser… (click the arrow, or type a character or two in the input box)
To see the power and flexibility of FlexBox, please check out all the demos!
Download the latest version of FlexBox, which includes the following files:
![]() |
Please note that by default, FlexBox expects to see files in this directory structure. If you need to move the “sel*.gif” image (which is a sprite for the arrow), be sure to update the css file to point to the new location. |
Add an empty div to the <body> tag wherever you want the FlexBox to appear:
Make sure you have a reference to jQuery, and the FlexBox js and css files in the <head> tag:
Also within the <head> tag, below the references to jQuery and FlexBox,
call the jQuery ready() function, and within it, call the FlexBox using the id
of the <div> you just created. The only parameter you must pass is the
page name that will return the results as a JSON string. You may also pass a
second parameter, which is a JSON object containing any of the Configuration
Options:
The call to results.aspx is ajax, and should return a JSON string in the format shown below.
{"results":[
{"id":1,"name":"Ant"},
{"id":2,"name":"Bear"},
{...} // more results here...
]}
Here are all the available options for customizing the FlexBox:
| Appearance |
| showArrow: boolean (default = true)
Set to false to simulate Google Suggest, which forces the user to type before results |
| showResults: boolean (default = true)
Set to false to hide the dropdown results. Exact matches appear immediately, |
| noResultsText: string (default = ‘No matching results’)
Text to display when there are no results matching what the user typed. |
| width: number (default = 200)
Specifies the overall width of the FlexBox. Automatically adjusts to |
| maxVisibleRows: number (default = 0)
When set to 0 (zero), this option is ignored. Otherwise, you can set |
| watermark: string (default = ”)
Helpful text that appears in the input box when it is loaded. |
| resultTemplate: string (default = ‘{name}’)
This very flexible property allows you to specify a template that is $('#fb').flexbox('results.aspx', {
resultTemplate:
'
{id}
' +
'
{name}
' } For each object in the JSON results array, the resultTemplate is applied, and the |
| Behavior |
| method: string (default = ‘GET’)
If ‘GET’, will call jQuery’s $.getJSON() function. If ‘POST’, will call jQuery’s |
| autoCompleteFirstMatch: boolean (default = false)
If set to true, the input box will automatically populate the first match for the text entered, |
| selectFirstMatch: boolean (default = true)
If set to true, the first matching item in the list will appear selected. |
| allowInput: boolean (default = true)
If set to false, behaves more like a standard <select> element, disallowing |
| queryDelay: number (default = 100)
The number of milliseconds to wait before the query is executed (after the user clicks or types in the FlexBox). |
| minChars: number (default = 1)
The minimum number of characters the user must enter before a search is executed. |
| highlightMatches: boolean (default = true)
Specifies whether the text the user types should be highlighted within the results. |
| highlightMatchesRegExModifier: string (default = ‘i’)
Specifies the type of RegEx modifier to apply when determining how to highlight matches.
|
| arrowQuery: string (default = ”)
The query to pass to the server when the arrow is clicked. By default, clicking the |
| onSelect: object (default = false)
The function to run when a result is selected. Use the full power of jQuery to write $('#fb').flexbox('results.aspx', {
onSelect: function() {
$('#fb-result').html('You selected "' + this.value + '", ' +
'which has a hidden value of ' +
this.getAttribute('hiddenValue'));
}
});
|
| maxCacheBytes: number (default = 32768)
The amount of data you will allow to be cached on the client side. Setting this |
| CSS Class Overrides |
| containerClass: string (default = ‘ffb’)
Overrides the name of the class for the main FlexBox div. |
| contentClass: string (default = ‘content’)
Overrides the name of the class for the content div. |
| inputClass: string (default = ‘ffb-input’)
Overrides the name of the class for the input element. |
| arrowClass: string (default = ‘ffb-arrow’)
Overrides the name of the class for the arrow image. |
| selectClass: string (default = ‘ffb-sel’)
Overrides the name of the class for “selected” items (rows). |
| matchClass: string (default = ‘ffb-match’)
Overrides the name of the class for showing where your query matches the result. |
| noResultsClass: string (default = ‘ffb-no-results’)
Specifies the class to apply to the noResultsText configuration options. |
| Form Field Values |
| displayValue: string (default = ‘name’)
JSON property whose value is displayed in the input box when a result is selected. |
| hiddenValue: string (default = ‘id’)
JSON property whose value is submitted when the form is submitted. Automatically |
| initialValue: string (default = ”)
Specifies the value that should appear in the input box when the FlexBox is loaded. |
| JSON Properties |
| resultsProperty: string (default = ‘results’)
JSON property in returned results that references the array of JSON objects |
| totalProperty: string (default = ‘total’)
JSON property in returned results that references the total number of results |
| Paging |
| paging: object
The paging object contains many properties to customize the appearance of the paging toolbar: paging: {
style: 'input', // or 'links'
cssClass: 'paging', // prefix with containerClass (e.g. .ffb .paging)
pageSize: 10 // acts as a threshold.
}
|
If setValue() is the only method, and allows you to set the display value of the input box after the FlexBox has loaded.
See jquery.flexbox.css for default styles. Important classes and attributes are commented.
Please use the Issue Tracker to view and report issues