自动填充无结果消息

时间:2017-07-10 15:06:14

标签: javascript jquery search autocomplete thymeleaf

你好,我有自动完成和百里香的这个表格



<script type="text/javascript" th:inline="javascript">
	/*<![CDATA[*/
	$(function(){
		  var currencies = [];
		  /*[# th:each="n : ${Locations}"]*/
		  currencies.push( {'value':"[(${n.name})] [(${n.address})]", 'Id':"[(${n.id})]"} );
		  /*[/]*/	  
		  $('#autocomplete').autocomplete({
		    lookup: currencies,
		    onSelect: function (suggestion) {
		     
        var Id = suggestion.Id; 
			  var requestData = { Id: Id };
			  yada.ajax([[@{/opinion}]], requestData, function(responseText, responseHtml) {
				      $('div.Inner').replaceWith(responseHtml);
				      yada.initHandlersOn(responseHtml);
				});
		    }
		  });
		});
	/*]]>*/
	</script>	
&#13;
<div id="searchfield">
	        <form>
	        	<i class="glyphicon glyphicon-search"></i>
	        	<input type="text" name="weblocation" class="biginput" id="autocomplete" placeholder="Search">
	        </form>
	      </div>
&#13;
&#13;
&#13;

我想显示消息,如果没有匹配条款:没有结果!

我该怎么办?

1 个答案:

答案 0 :(得分:0)

我找到了解决方案:

$('#autocomplete').autocomplete({
			showNoSuggestionNotice: true,
			noSuggestionNotice: 'Not result',

使用devbridge指南中的noSuggesionNotice:https://github.com/devbridge/jQuery-Autocomplete/pull/341/files?short_path=0730bb7