[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 310
  • Last Modified:

Customizing Coldfusion Autosuggestive Outputs

I am trying to customize what results the autosuggested value shows but am not having much luck other than it showing everything that starts with what is in the form field.

I want it to work like the following example where I can enter a string that is not necessarily the starting part of the string and it would suggest all strings that match the string typed in as a sub-string.

http://www.nodans.com/custom/examples/cf9/CustomAutosuggest/

Thanks in advance.
0
SFTProd
Asked:
SFTProd
  • 5
  • 3
1 Solution
 
_agx_Commented:
Is your source a CFC or a javascript function?
0
 
SFTProdAuthor Commented:
The source is a cfc.  For some reason, it has a tendency of only showing results that match stuff already typed into the form field at the beginning.  This happens no matter what data is returned by the CFC.
0
 
_agx_Commented:
Just getting back after a long w/e ..

typed into the form field at the beginning
That's controlled by the underlying js library. Changing the "queryMatchContains" setting to true should fix it.  You might also check out the betterautosuggest cfc at riaforge.org

<html>
<head>
<script type="text/javascript">
	var setFilter = function(){
		var lang = ColdFusion.objectCache[ 'language' ];
		lang.queryMatchContains = true;
	};	
</script>
</head>
<body>
<cfform>
<cfinput type="text" name="language" 
		autosuggest="cfc:MyComponent.test( {cfautosuggestvalue} )" />
		
		
</cfform>
<cfset ajaxOnLoad("setFilter")>

Open in new window


0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
SFTProdAuthor Commented:
I am getting the error message "setFilter is not defined."
0
 
_agx_Commented:
I tested it successfully w/CF9.  Are you running just the snippet posted or did you add the code to a larger form?
0
 
SFTProdAuthor Commented:
I took the following and put it in my header file between the head tags.  Once the page loads, I get the error.

<script type="text/javascript">
  var setFilter = function(){
  var lang = ColdFusion.objectCache[ 'language' ];
  lang.queryMatchContains = true;
  };      
</script>

<cfset ajaxOnLoad("setFilter")>
0
 
_agx_Commented:
Yeah, when I tested it CF was a bit picky about where the script tags where placed.  Try the sample code independently first.  If it works correctly, then it's probably something about the placement of the <script> it doesn't like.
0
 
_agx_Commented:
It works solo. So the problem is definitely the internal voodoo CF uses when placing it's auto generated code. If you're still having problems with it, just post your actual form code.

http://www.dansshorts.com/post/ajaxonloafd-and-cfhtmlhead


0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now