I am working with ColdFusion Server version 8,0,0,176276.
I am trying to add an autodiscover form field with asynchronous aggregation via cfc. I use http://www.forta.com/blog/index.cfm/2007/5/31/coldfusion-ajax-tutorial-1-autosuggest for inspiration and syntax.
The autosuggest field works fine if I use a static query (as in the first Forta example). Cfc successfully returns an array when not in use in a form field.
But when I use cfc for autosuggest, there are no suggestions.
I don’t see the contents of the input field with the "view source", but if I "check the item" in the field in Chrome, I see a div with class = "yui-ac-bd" and below it. List items in ul are empty when using cfc, while when using a static query, list items contain array elements.
Here is the code on my page:
<cfform>
<cfinput type="text" name="JobP"
autosuggest="cfc:autosuggest.AutoSuggest({cfautosuggestvalue})">
</cfform>
And here is autosuggest.cfc:
<cfcomponent output="false" >
<cffunction name="AutoSuggest" access="remote" returntype="array">
<cfargument name="ObjectType" required="false" default="JOBP">
<cfset var result=ArrayNew(1)>
<cfquery name="Objects" datasource="UC4MP">
SELECT oh_name
FROM uc4.oh
WHERE oh_otype = '#ObjectType#'
AND oh_deleteflag = 0
AND oh_lastdate > sysdate - 90
AND oh_client = 1000
and oh_name like 'A%'
ORDER BY oh_name
</cfquery>
<cfloop query="Objects">
<cfset ArrayAppend(result,oh_name)>
</cfloop>
<cfreturn result>
If I put the following code on my page, it will output an array with the desired content:
<cfinvoke component="autosuggest" method="AutoSuggest" returnVariable="result">
cfdump var="#result#">
I am not using jQuery yet; most of my google CF autocapture results are related to jQuery and I was unable to get through them due to my problem. Just in case, this will be your suggestion.