Изменения

SimpleAutocomplete/en

222 байта добавлено, 15:52, 5 марта 2013
м
Нет описания правки
Usage: include [{{SVN|vitaphoto/js/hinter.js}} hinter.js] and [{{SVN|vitaphoto/js/hinter.css}} hinter.css] on your page. Then write:
<source lang="code-javascript">var hint = new SimpleAutocomplete(input, dataLoader, multipleDelimiter, onChangeListener, maxHeight, emptyText, allowHTMLparams);</sourcecode>
Parameters:
; dataLoader(hint, value): Callback which should load autocomplete options and then call <tt>hint.replaceItems([ [ name, value ], [ name, value ], ... ])</tt>. 'hint' parameter will be this autocompleter object, and the guess should be done based on 'value' parameter (string).
Optional constructor parametersare passed as keys of the 'params' object:
; multipleDelimiter: Pass a delimiter string (for example ',' or ';') to enable multiple selection. Item values cannot have leading or trailing whitespace. Input value will consist of selected item values separated by this delimiter plus single space. dataLoader should handle it's 'value' parameter accordingly in this case, because it will be just the raw value of the input, probably with incomplete item or items, typed by the user.
; emptyText: Text to show when dataLoader returns no options. If emptyText === false, the hint will be hidden instead of showing text.
; allowHTML: If true, HTML code will be allowed in option names.
; promptHTML: HTML code to be always displayed before the option list when it's not empty.
 
When you don't need SimpleAutocomplete instance any more, you can destroy it with:
 
<code-javascript>
hint.remove();
hint = null;
</code-javascript>
Demo: