loopj/jquery-tokeninput — Issue #274: Special Characters in Autocompletion Items make find_value_and_highlight_term fail
Author: davidagraf
Created: 2012-02-07 08:52:05+00:00
State: open

Hello

I am having brakets in the autocompletion strings. This causes an error in the function find_value_and_highlight_term because of the RegExp that is created. I fixed the issue in the following way:

function find_value_and_highlight_term(template, value, term) {
// fix David Graf
var tmp = value.replace("\(","\\\(").replace("\)","\\\)");
return template.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + tmp + ")(?![^<>]*>)(?![^&;]+;)", "g"), highlight_term(value, term));
}

But I do not really like this fix because it just fixes my use case. A more general solution that allows the usage of all special characters would be nice.

Best
David