Skip to content
This repository was archived by the owner on Mar 16, 2018. It is now read-only.

autocomplete additions #34

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
#jQuery Autocomplete Plugin 1.2.2#
#jQuery Autocomplete Plugin 1.2.3#

##About this jQuery plugin##
Jörn Zaefferer’s (now deprecated into jQuery UI) [jQuery Autocomplete Plugin](http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/), with a small modification to enable UP/DOWN arrow keys, allowing navigation of input element text. This is particularly useful in cases where autocomplete is used in a textarea element where navigation of text via UP/DOWN arrow keys may be necessary. The tiny fix is documented with comments in the relevant lines on the development file (jquery.autocomplete.js). The .min and .pack files have the fix without specific annotation within the code.

We use it in Claritty.com for when a user wants to write a twitter username or a previously used hashtag within a new tweet, so “@” and “#” are trigger the script. While not triggered, though, the plugin still hijacks the UP/DOWN arrow keys making navigation of the text a pain in the ass when the user has multiple lines. This modification prevents this behavior, hijacking the arrow keys only when the autocomplete script has been triggered.

The original plugin is now deprecated, but this mod works well with jQuery 1.3.2 thru 1.4.4.
Jörn Zaefferer’s (now deprecated into jQuery UI) [jQuery Autocomplete Plugin](http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/) with various modifications (see changelog).

##Documentation##
Introduction to the original plugin, and an explanation of original plugin options are included in the docs folder. (Documentation at the jQuery site is expected to shut down eventually.)

This modification shouldn’t break any of the options discussed at the these documentation files.

##Abridged Changelog##
####1.2.3 --MLA####
* Added launchManual() method which allows you to force the autocomplete
to appear without user interaction

* Added refresh() method which reloads the autocomplete results

* Added afterItemSelect callback option which is called when an item
is selected from the autocomplete results

####1.2.2 --AGA####
* Merged agmcleaod’s fork: Added failure to the options hash: `failure`

Expand Down Expand Up @@ -40,4 +45,4 @@ _See_ changelog.txt _for pre-1.1.1 entries by original author._
##Licensing##
As with the original Plugin, this modification is dual licensed under the MIT and GPL licenses:
http://www.opensource.org/licenses/mit-license.php
http://www.gnu.org/licenses/gpl.html
http://www.gnu.org/licenses/gpl.html
16 changes: 15 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
1.2.3 --MLA

* Added launchManual() method which allows you to force the autocomplete
to appear without user interaction. Based on code from
stackoverflow.com/questions/3624518/open-autocompleter-results-div-on-textbox-click

* Added refresh() method which reloads the autocomplete results. This is
being used to modify/results the results based on other form elements.

* Added afterItemSelect callback option which is called when an item
is selected from the autocomplete results. This is being used to set
a separate hidden form element to keep track of a record ID behind
the scenes.

1.2.2 --AGA
---
*Merged agmcleaod's fork: Added failure to the options hash: `failure`
Expand Down Expand Up @@ -45,4 +59,4 @@
1.0
---

* First release.
* First release.
6 changes: 6 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,12 @@ <h3 id="siteSub">From jQuery JavaScript Library</h3>
</p><p><tr class="option"><td><b><a href="subs/setOptions.html" title="Plugins/Autocomplete/setOptions">setOptions(&nbsp;options )</a></b></td><td class="default"><b>Returns:</b> <span>jQuery</span></td></tr><tr><td colspan="2" class="desc">Updates the options for the current autocomplete field.</td></tr>
</p><p><br />
</p><p><br />
</p><p><tr class="option"><td><b><a href="#">launchManual()</a></b></td><td class="default"><b>Returns:</b> <span>jQuery</span></td></tr><tr><td colspan="2" class="desc">Triggers autocompletion without user interaction.</td></tr>
</p><p><br />
</p><p><br />
</p><p><tr class="option"><td><b><a href="#">refresh()</a></b></td><td class="default"><b>Returns:</b> <span>jQuery</span></td></tr><tr><td colspan="2" class="desc">Flushes any cached data and reloads autocomplete results.</td></tr>
</p><p><br />
</p><p><br />
</tbody></table></div>
</p>
<div class="editsection" style="float:right;margin-left:5px;">[<a href="/action/edit/Plugins/Autocomplete?section=4" title="Edit section: Demos">edit</a>]</div><a name="Demos"></a><h2> Demos </h2>
Expand Down
4 changes: 3 additions & 1 deletion docs/subs/autocomplete_options.html
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,9 @@ <h3 id="siteSub">From jQuery JavaScript Library</h3>
Remote options:</div></div><div class="args"><b class="args">Arguments:</b><table class="args" cellspacing="0"><tr class="option"><th>url or data</th><td class="type">String, Array</td><td class="default"></td></tr><tr><td colspan="3" class="desc">An URL pointing at a remote resource or local data as an array.</td></tr><br /><tr class="option"><th>options<span class="optional"> (Optional)</span></th><td class="type">Options</td><td class="default"></td></tr><tr><td colspan="3" class="desc">A set of key/value pairs that configure the autocomplete. All options are optional.</td></tr></table></div> </div>
<p><br />
<div id="toptions" class="options tabs-container"><b class="options">Options:</b><table class="options" cellspacing="0"><thead><tr><th>Name</th><th>Type</th></tr></thead><tbody>
</p><p><tr class="option"><th>autoFill</th><td class="type">Boolean</td><td class="default"><b>Default:</b> <span>false</span></td></tr><tr><td colspan="3" class="desc">Fill the textinput while still selecting a value, replacing the value if more is typed or something else is selected.</td></tr>
</p><p>
<tr class="option"><th>afterItemSelected</th><td class="type">Function</td><td class="default"><b>Default:</b> <span>none</span></td></tr><tr><td colspan="3" class="desc">Optional callback for when an item is selected from the autocomplete results. The function is passed the selected data item along with the input element.</td></tr>
<tr class="option"><th>autoFill</th><td class="type">Boolean</td><td class="default"><b>Default:</b> <span>false</span></td></tr><tr><td colspan="3" class="desc">Fill the textinput while still selecting a value, replacing the value if more is typed or something else is selected.</td></tr>
<tr class="option"><th>cacheLength</th><td class="type">Number</td><td class="default"><b>Default:</b> <span>10</span></td></tr><tr><td colspan="3" class="desc">The number of backend query results to store in cache. If set to 1 (the current result), no caching will happen. Must be &gt;= 1.</td></tr>
<tr class="option"><th>delay</th><td class="type">Number</td><td class="default"><b>Default:</b> <span>400 for remote, 10 for local</span></td></tr><tr><td colspan="3" class="desc">The delay in milliseconds the autocompleter waits after a keystroke to activate itself.</td></tr>
<tr class="option"><th>extraParams</th><td class="type">Object</td><td class="default"></td></tr><tr><td colspan="3" class="desc">Extra parameters for the backend. If you were to specify { bar:4 }, the autocompleter would call my_autocomplete_backend.php?q=foo&amp;bar=4 (assuming the input box contains &quot;foo&quot;). The param can be a function that is called to calculate the param before each request.</td></tr>
Expand Down
Loading