Solved

jquery autocomplete

Posted on 2014-07-21
5
249 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
This article discusses how to create an extensible mechanism for linked drop downs.
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)

777 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