I have nodes with special chars like ą š ų ū and if I search for uxx it will NOT return ūxx or ųxxx, search plugn match exact match, how to change that?
Current code snippet for searching:
$('#tree_search').keyup(function(){
if(to) { clearTimeout(to); }
to = setTimeout(function () {
var v = $('#tree_search').val();
$('#tree-wrap').jstree(false).search(v);
},250);
});
UPDATE: so I manage to insert callback function but in this function only last element of array working as expected ė == e so I think this is for loop issue but can't figure out what exactly...
var defaultDiacriticsRemovalMap = [
{'base':'z','letters':/[\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763]/g},
{'base':'e', 'letters':/[\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD]/g}
];
var tempSearchString;
for( var i = 0; i < defaultDiacriticsRemovalMap.length; i++ ) {
tempSearchString = searchString.replace(defaultDiacriticsRemovalMap[i].letters, defaultDiacriticsRemovalMap[i].base).toLowerCase();
}
var text = node.text;
for( var i = 0; i < defaultDiacriticsRemovalMap.length; i++ ) {
text = (node.text || '').replace(defaultDiacriticsRemovalMap[i].letters, defaultDiacriticsRemovalMap[i].base).toLowerCase();
}
return ((text || '').indexOf(tempSearchString) != -1)
Here is what i use in my code to escape accents (Warning: huge diacritics array) :
A bit of an explanation:
The search_callback is called on every node of the jsTree and the node itself is passed as an argument to the function.
We loop through the search text string to remove the accents first and replace them with the base.
Then we do the same for the node text and finally we can easily compare them using nodeText.indexOf(searchString). If the searchString is not in the nodeText, it returns -1.
The .toLowerCase() is facultative. In my case, we wanted to ignore the capital letters too.
edit: Forgot to mention that tempSearchString was assigned with the seachString because we use the variable itself while looping to replace the accents with their matching base.