FlexBox Home Page
FlexBox CodePlex Project Page
FlexBox jQuery Plugin Page

FlexBox Demos

Return to FlexBox Overview

Using FlexBox

Examples

Example 1: ComboBox, with dynamic paged data
Code: FlexBox:
Notes:
  • Click the arrow, or click in the input box and type the letter "m" to see a list of matching countries
  • Or, 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 2: Like Google Suggest (hide the arrow)
Code: FlexBox:
Notes:
  • Set showArrow to false to hide it, and use FlexBox just like you use Google Search
Example 3: Straight type-ahead (hide the dropdown)
Code: FlexBox:
Notes:
  • Hide the results entirely, but automatically complete the first matching element. You can use this when you already know all of the items, and don't need to see the whole list (e.g. selecting a U.S. state). It keeps your forms nice and compact...
Example 4: Disable paging (no scrolling), new width
Code: FlexBox:
Notes:
  • In this example, we override the default width, and turn off paging entirely. Watch out though, this is most likely not what you want for long lists (like the one in the example!).
Example 5: Force Scrolling, Show Watermark
Code: FlexBox:
Notes:
  • The watermark is a nice touch, and helps your users without compromising screen real estate. In this example we are also limiting the number of visible rows, which is usually a good idea if paging is turned off. This is a much more practical example than Example 4.
Example 6: 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 7: Create a template for each matching result, and call a JavaScript function when a result is selected
Code: FlexBox:
Notes:
  • My favorite example... You can use your own html as a template for each row (result). If you surround the name of a valid JSON property in curly braces, that value will be merged in for each row. In this case, we have a folder full of images that are named based on the two-letter country code (represented by {id}). We are also styling the "col1" and "col2" divs by floating them left and giving them a width.
Example 8: 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 "ffb8" form field will contain the typed-in value.
Example 9: Simulate <select> tag by disallowing input
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 10: Large data set
Code: FlexBox:
Notes:
  • This data set is generated dynamically on every page load, and contains 10,000 items. Notice that although the data set is quite large, performance is excellent.