easyautocomplete:是否可以将数组传递给getValue方法?

时间:2017-02-17 13:19:36

标签: json easyautocomplete

例如,我想同时在“名称”和“代码”字段中搜索单词。我怎样才能做到这一点? 也许是这样的: getValue:“name”,“code”,

var options = {
	url: "http://easyautocomplete.com/resources/countries.json",

	getValue: "name",

	list: {
		match: {
			enabled: true
		}
	}
};

$("#provider").easyAutocomplete(options);
<html lang="en">
<head>
  <meta charset="utf-8">

  <title>Test</title>

  <!--[if lt IE 9]>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
  <![endif]-->
</head>

<body>
<input type="text" id="provider"/>


  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://easyautocomplete.com/dist/jquery.easy-autocomplete.min.js"></script>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

您应该能够将函数传递给getValue选项,如下所示:

     getValue: function(element) {
         var my_value = element.name + ' ' + element.code;
         return my_value;
     },

有关详情,请参见他们的docs