Return to FlexBox Overview
Using FlexBox
- In all of the examples that call "results.aspx", the data is a list of 105 english words
- Click in the input box, and type a single letter, such as "a"
- Click the arrow on the right of the FlexBox, or click in the input box and tap the "Enter" or "Down Arrow" key on your keyboard
- Try using up and down arrow to scroll through results, and tap the "Enter" key to select an option
- If there are multiple pages of results, you can click the paging links, or use the left and right arrow keys to navigate between pages
- Tap the escape key to hide the dropdown when the input box has focus
Examples
Example 1: Default, with static data |
|
Code:
|
FlexBox:
|
Notes:
- The most basic implementation is not very useful...please see the other examples below
- json.txt contains the following data:
|
Example 2: ComboBox, with dynamic paged data |
|
Code:
|
FlexBox:
|
Notes:
- Click in the box and type some non-matching characters, such as 'xyz', to see the default behavior when there are no matching results
|
Example 3: Like Google Suggest (hide the arrow) |
|
Code:
|
FlexBox:
|
|
Notes:
|
Example 4: Straight type-ahead (hide the dropdown) |
|
Code:
|
FlexBox:
|
|
Notes:
|
Example 5: Disable paging (no scrolling), new width |
|
Code:
|
FlexBox:
|
|
Notes:
|
Example 6: Force Scrolling, Show Watermark, use POST |
|
Code:
|
FlexBox:
|
|
Notes:
|
Example 7: Set an initial value, and change the page size |
|
Code:
|
FlexBox:
|
Notes:
-
You can use the setValue() function instead of the initialValue configuration option,
if you need to set the initial value based on data that is not available when the FlexBox is loaded:
|
Example 8: Create a template for each matching result, and call a JavaScript function when a result is selected |
|
Code:
|
FlexBox:
|
|
Notes:
|
|
Example 9: Do not auto-complete the first match, and allow new values
|
|
Code:
|
FlexBox:
|
Notes:
- If a new value is entered into the input box, and the form is submitted,
the "ffb9" form field will be an empty string, since there is no corresponding
"id" value. To access the typed-in value when the form is submitted,
check for "ffb9_input" in the posted form variables.
|
|
Example 10: Simulate <select> tag, and pass a JSON object as the first parameter (do not retrieve data from url)
|
|
Code:
|
FlexBox:
|
Notes:
-
Allows you to bind to local data, or chain multiple FlexBoxes. The first FlexBox
can populate a "child" FlexBox based on a $.getJSON() call within the first FlexBox's
onSelect function:
In the future, I plan to make it much easier to handle chained, or dependant dropdowns.
|
|
Example 11: Static data, with client-side paging (no autocomplete support)
|
|
Code:
|
FlexBox:
|
Notes:
-
Allows you to load all data up front (client or server side), and page through that data on the client side.
Note that this depends on FlexBox caching, so the "maxCacheBytes" configuration option must be greater than zero!
I have not yet implemented querying/autocomplete against client-side data, but plan to in the future...
|