With a little side of applesauce...

Monday, December 22, 2008

Coldfusion - autosuggest matches from beginning of string by default

After a bit of debugging foo, I realized that autosuggest in Coldfusion 8 matches results from the beginning of the string, therefore a search for "Joh" would give me a drop-down menu to choose the correct "John Smith", but a search for "Smith" would not give me a drop-down menu, even though I would receive the following result set from the server:

info:http: CFC invocation response: ["John Smith"]

Finally, I found that you have to modify CFIDE/scripts/ajax/yui/autocomplete/autocomplete-min.js, which is invoked with the autosuggest attribute and change the following from:

YAHOO.widget.DataSource.prototype.queryMatchContains = false;

To:
YAHOO.widget.DataSource.prototype.queryMatchContains = true;

What a drag for anyone that has to get this changed on a production server...

The answer was found here.

EDIT: A better solution is to copy CFIDE/scripts/ajax/yui/autocomplete/autocomplete-min.js to a folder in your web, and then import that into your header, which preempts the version in CFIDE/scripts/ajax/yui/autocomplete. This is the only solution, if your sys admin doesn't want to make the change globally, (and who would blame them?):
<script type="text/javascript" src="js/autocomplete-min.js"></script>

No comments: