Coldfusion自动提示不适用于字符串中间的建议 [英] Coldfusion autosuggest not working for suggestions in the middle of the string

查看:12
本文介绍了Coldfusion自动提示不适用于字符串中间的建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的自动建议,我使用下面的代码.

For my autosuggest I'm using the code below.

键入时,它只查看字符串的开头.例如,如果我输入abcd",它会附带建议abcde...",这很好.

When typing, it only looks at the beginning of the string. For example if I type 'abcd' it will come with suggestions 'abcde...' that is good.

但是它没有做什么,如果我输入def"并且在数据库中我有一个字符串abcdefg",那么这不会出现在自动建议中.

But what it doesn't do, if I type 'def' and in the database I have a string 'abcdefg' then this doesn't come in the autosuggest.

在我的查询中,搜索字符串前后都有百分比字符.

In my query I do have the percent characters infront and behind the search string.

所以在我看来,自动提示似乎只查看开头输入的字符,而不是中间.

So to me it looks like the autosuggest only looks at the characters typed at the beginning, not in the middle.

还是我做错了什么?

<cfcomponent output="false">

    <cffunction name="lookupJobs" access="remote" returntype="array">
       <cfargument name="search" type="any" required="false" default="">

       <cfset var qGetJobs="">
       <cfset var result=ArrayNew(1)>
       <cfquery name="qGetJobs" datasource="#application.dsn#"> 
          SELECT DISTINCT title
          FROM tbl_jobs  
          WHERE  title LIKE '%#arguments.search#%' 
          ORDER BY title
       </cfquery> 
       <cfloop query="qGetJobs">
           <cfset ArrayAppend(result, title)>
       </cfloop>
       <cfreturn result>
    </cffunction>

</cfcomponent>

推荐答案

感谢 Leigh,解决方案是使用 cfinput.

Thanks to Leigh, the solution was with the cfinput.

<cfinput type="text" name="title" 
      showautosuggestloadingicon="false"
      autosuggest="cfc:autosuggest.lookupJobs({cfautosuggestvalue})"   
      matchContains="true">

我需要添加属性:matchContains="真"

这篇关于Coldfusion自动提示不适用于字符串中间的建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆