Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

jquery autocomplete

Posted on 2014-07-21
5
Medium Priority
?
255 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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)
Suggested Courses

721 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