Home  >  Article  >  Web Front-end  >  The improved version of combox refers to the page prototype of dojo. It has stronger functions and smaller code than the jQuery combox on the Internet_javascript skills

The improved version of combox refers to the page prototype of dojo. It has stronger functions and smaller code than the jQuery combox on the Internet_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:29:22881browse

Introduction
For the minimal js code to implement the combo function, the page prototype refers to the combo box appearance of dojo, which supports keyboard actions, automatic filtering, highlighting, etc.

API
Initialization method
Coding method
var c=new combox(document.getElementById('a'));
or
var c=new combox(document.getElementById('a'),{ debug:true });
Css declaration method


or

Configuration parameter description
combox supports the following configuration parameters:

debug: true/false, whether to display the original select element It can be seen that
searchMode: 0 is fuzzy case-insensitive, 1 is prefix search case-insensitive
remoteSourceUrl: remote data source url, supports json format as follows
[
{"text":" a","value":"b"}, {"text":"a1","value":"b1"}
]
remoteFilterUrl: The remote url read during filtering, the parameter is xxxx? asdasd=~!value!~, ~!value!~ is a macro, which will be replaced by the value of the current input box when triggered
allowAnyValue: The default is false, and the combobox is not allowed to input data other than options
displayValue :The display value of the combobox. When displayValue can find the corresponding value in the options of the combobox, it displays the text of the option. Otherwise, it displays the displayValue
pleaseSelect: When the txtBox value of the combobox is the text of pleaseSelect, the drop-down Expand all options
mouseDblClick:0 means single click, 1 means double click
Example:

var c=new combox(document.getElementById('a'),{
allowAnyValue:true ,
pleasSelect:'Please select',
debug:true })
or

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn