Project

General

Profile

Actions

Anomalie #473

closed

Make autocompletion works with accents

Added by Simon over 9 years ago. Updated over 9 years ago.

Status:
Fermé
Priority:
Normal
Assignee:
Category:
admin
Target version:
Start date:
04/24/2015
Due date:
% Done:

100%

Estimated time:
(Total: 2.00 h)
Resolution:


Subtasks 1 (0 open1 closed)

Evolution #487: use alternative libray for multiselectFerméSimon04/24/2015

Actions
Actions #2

Updated by Simon over 9 years ago

Implementing https://select2.github.io/ to autocomplete will also replace multiselect library since it also covers this feature

Actions #3

Updated by Simon over 9 years ago

https://select2.github.io/ relies on select box, so it won't let user enter values if javascript is disabled. Don't like this idea

https://github.com/devbridge/jQuery-Autocomplete should be a good alternative

Actions #5

Updated by Simon over 9 years ago

  • Status changed from Nouveau to Fermé
  • % Done changed from 0 to 100

Applied in changeset linea21|r2803.

Actions #6

Updated by Simon over 9 years ago

Solution came from here :

http://stackoverflow.com/questions/2127124/utf-8-problem-in-using-jquery-autocomplete-tags

$.TextboxList.Autocomplete.Methods = {

    standard: {
        filter: function(values, search, insensitive, max){
            var newvals = [];
            // fix @simo
            // regexp = new RegExp('\\b' + escapeRegExp(search), insensitive ? 'i' : '');
            // http://stackoverflow.com/questions/2127124/utf-8-problem-in-using-jquery-autocomplete-tags
            regexp = new RegExp('' + escapeRegExp(search), insensitive ? 'i' : '');

            for (var i = 0; i < values.length; i++){
                if (newvals.length === max) break;
                if (regexp.test(values[i][1])) newvals.push(values[i]);
            }
            return newvals;
        },

        highlight: function(element, search, insensitive, klass){
            // var regex = new RegExp('(<[^>]*>)|(\\b'+ escapeRegExp(search) +')', insensitive ? 'ig' : 'g');
            var regex = new RegExp('(<[^>]*>)|('+ escapeRegExp(search) +')', insensitive ? 'ig' : 'g');

            return element.html(element.html().replace(regex, function(a, b, c){
                return (a.charAt(0) == '<') ? a : '<strong class="'+ klass +'">' + c + '</strong>'; 
            }));
        }
    }

};
Actions

Also available in: Atom PDF