4 This template enables auto completion for input fields.
7 INCLUDE 'generic/autocomlete', [
13 where SPEC is a hash containing the following keys:
15 script : the script that is called for autocompletion, defaults to the invoking script
16 action : action in the ajax script, defaults to 'ajax_autocomplete'
17 selector : a jquery selector, specifying the input field
18 column : specifies the column that is represented by the bound field. typically description or name.
21 - addition fields like type, vc etc.
22 - additional dependencies, see jquery.autocomplete documentation
23 - hook function on select, again see jquery documentation
25 a simple SPEC would look like this:
27 { selector => '#description', column => 'description' }
28 # field with id="description" should be autocompleted with descriptions
30 { script => 'ic.pl', selector => '[name^="partnumber_"]', column => 'partnumber' }
31 # let ic.pl autocomplete by partnumbers, bind this to all fields where the name begins with "partnumber_"
37 The called function will recieve the queried string as hashkey "q" in form, as well as every other param specified here.
38 It should generate a generic ajax header (see form), followed by newline separated list of possible completion values.
41 <script type='text/javascript'>
42 [%- FOREACH token = AUTOCOMPLETES %]
43 [%- DEFAULT token.script = script %]
44 [%- DEFAULT token.action = 'ajax_autocomplete' %]
45 [%- DEFAULT token.INPUT_ENCODING = 'utf8' %]
46 [%- token.url = token.script
47 _ '?action=' _ token.action
48 _ '&INPUT_ENCODING=' _ token.INPUT_ENCODING %]
49 [%- SET token.url = token.url _ '&column=' _ token.column IF token.column %]
50 $(document).ready( $('[% token.selector %]').autocomplete('[% token.url %]'));