Solved

jquery autocomplete

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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 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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now