Places

 

  • Download
  • Documentation
  • Forums
  • Demo
  • Contact
  • Blog
  • My account

Meteora

Javascript Widgets

Controls

  • Autocomplete
  • Bubble
  • Calendar
  • Carousel
  • Datagrid
  • Dialog
  • Editor
  • Filebrowser
  • Form Control
  • Menu
  • Notebook
  • Picbox
  • Popup
  • Searchlist
  • Selection
  • Spinbutton
  • Tablesort
  • Toolbox
  • Treeview

Features

  • JsonRpc Core

Effects

  • Visual effects

Control.Autocomplete

Before proceeding you may want to read our getting started page.

What does this control do?

This control predicts the word or phrase the user wants to type in without actually typing it in completely. Nobody enjoys filling out forms!

For an usage example check out the Control.Autocomplete demo.

How to use it

In order to be able to use this control, paste this line of javascript right at the beginning of your script tag:

Meteora.uses('Control.Autocomplete');

An external input tag is required to attach the control:

<input type="text" name="name_of_the_input" id="test-input" />

You may then be able to invoke the Autocomplete Widget

new Autocomplete(

  // ELEMENT
  // The input's id (or an element's reference)
  'test-input',

  // OPTIONS
  {
    // Where to query for results, this response
    // requires a special format.
    'action': '/search/server-side-script',

    // What to do when the user clicks a result.
    'onClick': function(data) {
      // You may want to do something else
      alert('index: '+data.index+', content: '+data.content);
    }

  }
);

Server side response

This control will query for a special formatted result to the URL you specified in the action option. /search/server-side-script?name_of_the_input=value As value, it will send the text that is currently inside the input.

Here is a server side response example:

{
  "AF":"Afghanistan",
  "AL":"Albania",
  "DZ":"Algeria",
  "AS":"American Samoa",
  "AD":"Andorra",
  "AO":"Angola",
  "AI":"Anguilla",
  "AQ":"Antarctica",
  "AG":"Antigua and Barbuda",
  "AR":"Argentina"
}
To generate this response using PHP you'll have to write something like this:
$json->response(
  array(
    'AF' => 'Afghanistan',
    'AL' => 'Albania',
    'DZ' => 'Algeria',
    'AS' => 'American Samoa',
    'AD' => 'Andorra',
    'AO' => 'Angola',
    'AI' => 'Anguilla',
    'AQ' => 'Antarctica',
    'AG' => 'Antigua and Barbuda',
    'AR' => 'Argentina'
  )
);

Options

autoClose (default: true)

If true, allows the autocomplete interface to be automatically closed when the input loses it focus.

autoSelect (default: true)

If true, when any matches are found while typing the control will automatically highlight them.

onClick (default: null callback)

Action to call when the user clicks in any result.

Methods

close()

Closes the results div.

search()

Requests for results and shows the results div.

timedSearch()

A delayed call to search(), useful to detect when the user finished typing.

Powered by textmotion

(c) 2008 Astrata Software