chinese
Dear My language is Chinese. If I type one Chinese char only the suggestion cannot be shown. there is no error I can check on developer tool of Chrome. My version is 1.2.14
if I type english or number or both the suggestion is shown and work very well.
Could you help this issue? Thanks Martin
Dear Again I try to narrow the problem.
a. i try to verify the outcome of ajax. English / number / chinese are OK.
It means I can get objects of suggestions and query in English and Chinese onSearchComplete: function (query, suggestions) { console.log(query); console.log(suggestions); },
b. I try to format the result before it s displayed English / number OK. Chinese is not OK. It means I cannot get objects. it is .
formatResult: function (suggestion, currentValue) { console.log(suggestion); console.log(currentValue); }
MARTIN
update
autocomplete is upgraded to 1.2.16
martin
Maybe it's just issue when trying to highlight result. Try providing your own formatResult function and see if you can get it to work.
Dear tkirda At first I think maybe it is the reason of highlight result. So I was trying to implment the formatResult: function (suggestion, currentValue) function by myself. from the document there are two arguments suggestion and currentValue. I cannot get any object/value from there two arguments. And then I cannot format the result by myself. I log these two arguments. [] is the outcome of suggestion. currentValue is empty.
I don't know why. Could you give me idea?
Martin
Dear tkirda
I update my status.
-
I don't provide my formatResult function. I just set triggerSelectOnValidInput to false only. Chinese is working well. Many thanks for your great script.
-
I checked the code. I found that the problem is from following codes. I make comment as well for your reference
if (options.triggerSelectOnValidInput) { index = that.findSuggestionIndex(value); if (index !== -1) { // Chinese get into this loop, but others don't // that.suggestions array is OK that.select(index); // that.suggestions array is not OK and it is like to be disappeared return; } }
so Why Chinese words get into the if statement only? Why that.suggestions array is disappeared? These are reasons I think Chinese cannot use this script. So I set triggerSelectOnValidInput option to false. this script works
- What the triggerSelectOnValidInput option for? May I know that. from your document I cannot know it clearly. something is confused.
I give my script information for your reference
var suggest = jQuery('#searchword').autocomplete({
serviceUrl: '" . JRoute::_('index.php?option=com_finder&task=suggestions.suggest&format=json&tmpl=component', false) . "',
paramName: 'q',
minChars: 1,
maxHeight: 400,
width: 300,
zIndex: 9999,
appendTo: '#suggestions-container',
forceFixPosition: true,
deferRequestBy: 200,
triggerSelectOnValidInput: false
});"
and it is the version of 1.2.16
Best Regards Martin
Martin, thanks for your comments and research.
Can you provide me those strings in Chinese, I would like to test them and resolve the issue.
Dear tkirda Sure , I provide the following Chinese to you. 醫 or 醫生(English is doctor)
I used these Chinese to test my developing site. My developing site is on http://dev-tzuchi.rhcloud.com/. (This is a hospital website) You can test it with above Chinese.
Now it works since I set triggerSelectOnValidInput to false.
Just let me know If you need more help.
Best Regards Martin
我使用的是中文,输入之后,传输到后台页面的数据,是乱码?使用英文和数字,该插件运行正常。期待解答!
@HelloTonny 你该不会以为作者看得懂中文吧……
- 传到后台的数据是乱码,你应该在后台转一下码。一般最好把前后端的编码统一成 utf8。
- 这个插件的 ajax 用的是 jquery,如果服务器传回来的是乱码。你可以在
ajaxSettings里面加上contentType: "application/json; charset=utf-8"试一下,强制使用utf-8编码。不行你就改下你服务器的编码,或者再试下gbk。
To tkirda: He is having an encoding issue, the data transmitted to his backend is all messy. Not sure it's whether a HTML problem or server-side problem, but I reckon definitely not your wrapper's problem.