AutoCompletePlugin
This plugin allows you to create an autocomplete input field based on Yahoo's User Interface Library.
This plugin originally implemented Arthur Clemens'
Foswiki:Extensions/AutoCompleteAddOn as a extension, which allows users to provide an autocomplete text box using the
%AUTOCOMPLETE%
syntax, and also in
DataForms (shown below), but has since grown in its own right.
Usage
Before you can use this plugin, you need to set up some data for the autocomplete. Examples can be found at
AutoCompletePluginTestData.
In Topics and Templates
This plugin expands the
%AUTOCOMPLETE{...}%
variable, which takes the parameters described in
AutoCompletePlugin.
In DataForms
To use this plugin in
DataForms, create a form template as descibed in
DataForms. This plugin adds the
autocomplete
type of field. To pass the parameters required by the plugin, place them in the
Values
column. An example is shown below:
You can use many of same attributes as you would in topics, except the following:
-
name
-
size
-
value
-
class
-
formname
For a working example of this, see
AutoCompletePluginFormExample.
Parameters
Parameter |
Comment |
Default |
Example |
name |
A unique name for the textfield |
required |
name="users" |
datatopic |
The topic with data. Should be formatted as comma-separated string, or as an array of arrays (see AutoCompletePluginTestData for an example). Use with datasection . |
required |
datatopic="Sandbox.AutoCompletePluginTestData" |
datasection |
The topic section with data. Use with datatopic . |
required |
datasection="usernames" |
size |
The width of the input field in em or px. |
20em |
size="20em" or size="200px" |
value |
Default value of the input field |
none |
value="AutoCompletePlugin" |
tabindex |
The tabindex of the textfield |
none |
tabindex="2" |
class |
Name of css class to add to the input field |
none |
class="foswikiInputField" |
formname |
Name of the form which the input field is part of |
none |
form="userlist" |
itemformat |
The format of an item string in the autocomplete list. Use if the autocomplete list should display different names than the input field - for instance with full person names. The javascript input argument is item . |
item |
itemformat="item[0] + ' (' + item[1] + ')'" |
delimchar |
Used to accept multiple delimeted queries. |
none |
delimchar="," |
onblur , onfocus , onchange , onselect , onmouseover , onmouseout |
Javascript parameters for the textfield. |
none |
onfocus="foswiki.Form.clearBeforeFocusText(this);" |
itemselecthandler |
Defines a javascript function to be executed when an item is selected. See http://developer.yahoo.com/yui/autocomplete/#customevents. |
none |
itemselecthandler="submitJumpForm" |
Example
If installed, the following should create an jump box:
Source:
<script type="text/javascript">
var SubmitJump = function(sType, aArgs) {
document.myJumpForm.submit();
}
</script>
<form name="myJumpForm" action="%SCRIPTURLPATH{"view"}%/%BASEWEB%/%BASETOPIC%">%AUTOCOMPLETE{name="topic" datatopic="Sandbox.AutoCompletePluginTestData" onfocus="foswiki.Form.clearBeforeFocusText(this);" onblur="foswiki.Form.restoreBeforeFocusText(this);" datasection="topiclist" value="Jump" formname="myJumpForm" class="foswikiInputField foswikiInputFieldBeforeFocus" itemselecthandler="SubmitJump" size="128px" }%</form>
Rendered:
Installation Instructions
You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.
Open configure, and open the "Extensions" section. Use "Find More Extensions" to get a list of available extensions. Select "Install".
If you have any problems, or if the extension isn't available in
configure
, then you can still install manually from the command-line. See
http://foswiki.org/Support/ManuallyInstallingExtensions for more help.
Debugging
Debug information will be generated if the following preference is set in
SitePreferences:
- Set AUTOCOMPLETEPLUGIN_DEBUG = 1
Note: Setting it here will have no effect.
Plugin Info
Related Topics: Plugins,
DeveloperDocumentationCategory,
AdminDocumentationCategory,
DefaultPreferences,
SitePreferences