Solved

jquery autocomplete

Posted on 2014-07-21
5
252 Views
Last Modified: 2014-07-28
Below is some jquery code which uses autocomplete to supply a user with a list of artist names. It works correctly except when there is an accent in the name. (for example Jiménez will not be in the list if you type "Jime...). I think I have to add an accent map but since I'm using a file, autocompleteArtist.cfm,which returns the data,  rather than a variable with some text names,  I'm not sure what the code should be with the accent map.
Here is what I have:
<script type="text/javascript">
                  // autocomplete typeahead additions
       	          $(document).ready(function() {
			
	            $("#txtArtistName").autocomplete({
                source: "autocompleteArtist.cfm",
	                minLength: 2,
					delay:0
	                
	            });
	        });                               
  	</script> 

Open in new window


Can someone tell me what the code should be to display accents here?
Thank you.
0
Comment
Question by:cbeverly
  • 3
5 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 40210551
you're not using UTF8 anywhere, it's time to update your database character set, good luck, backup first
0
 
LVL 52

Expert Comment

by:_agx_
ID: 40211428
(no points... I don't have answer)

@leakim971 - Sounds like more than just a simple encoding question. If I'm understanding correctly, when a user types a word with "e" (ascii 101), they want it to actually match words with "é" (ascii 138 ?) too. That shouldn't normally work because they're 2 totally different characters.  

Not sure if that's possible or if it is  - how it could be done :)
0
 

Author Comment

by:cbeverly
ID: 40211479
Yes, you are correct - when a user types a normal e they want it to match with é. So if they type "Jimenez" they want it to match Jiménez. I think I have to use an accent map but don't know how to get it to work with the autocomplete method I'm using.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 40212683
It sounds like there are two parts to this: server and client side. The db query itself has to account for "e" vs "é". Otherwise it won't return "Jiménez" to the jquery function in the first place. So I think you need more than a client side map..

Honestly, I'm not sure if there's a simple way to do that in SQL. You might want to ask someone in the MySQL zone. (I'd leave CF out of it, so as not to discourage folks unfamiliar w/CF. Plus it is really a SQL question). Just explain you're running a query that's used for an autocomplete feature. You'd like the parameter "Jime%" to also match Jiménez". Ask if there's a way to handle that:

     ie   Where "'Jime" is a variable parameter

               SELECT  ColumnA, ColumnB
               FROM     SomeTable
               WHERE  ColumnA LIKE 'Jime%'
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 40213211
> Otherwise it won't return "Jiménez"

Hm... that may not be entirely correct.  I was reading this (old) thread which mentions collation. Apparently the results depend on the collation of your column.  In this sql fiddle, the "é" is treated just like "e". I don't know if changing the collation has any negative impact, but .. if that does the trick for the db side, then you just need to figure out the client side/javascript mapping.
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CFSPREADSHEET CF2016 overwrites single sheet 22 36
Send form to asp server side 6 26
Video Tutorial help 2 37
what should i learn? javascript or typescript? 3 33
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question