Coldfusion autosuggest not working for suggestions in the middle of the string

Viewed 439

For my autosuggest I'm using the code below.

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.

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.

Or am I doing something wrong?

<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>
1 Answers
Related