3
I’m using the Chosen on my forms, but I’d like him to ignore the accents when filtering.
For example: In a city listing, filter the correctly to:
- africa
But it does not filter to (because the words differ by the accent):
- Africa
In the project’s Github, there are already discussions on this since 12/03/2012 (https://github.com/harvesthq/chosen/issues/536), but have not yet implemented this in the official code.
Reading the existing discussions, I found this functional example, posted by @felpasl:
- Working example: http://fiddle.jshell.net/whqb5/1/
However, I intend to implement its operation, but without changing the original sources, to minimize future complications when updating the code from the official repository.
I thought about replacing the method, externally, but I’m not able to do it. Below the code I tried, to replace the method...
var Chosen = $('#campo_select_com_chosen').chosen();
Chosen.prototype.search_string_match = function (search_string, regex) {
alert('Método substituído com sucesso');
};
But I get this mistake:
Uncaught Typeerror: Cannot set Property 'search_string_match' of Undefined
My difficulty is in how to replace a lib method that I am using without altering the lib sources. If it were in PHP I would inherit the class and replace the method... but in Javascript I do not know how to do.
Could someone help me on how to do this implementation, Plugin type, on Chosen?
http://answall.com/questions/3994/como-fazer-uma-busca-ignorando-acentuação-em-javascript
– bfavaretto
@bfavaretto once again thank you for your support. My difficulty is in how to replace a lib method that I am using without altering the lib sources. If it were in PHP I would inherit the class and replace the method... but in Javascript I do not know how to do.
– Allan Andrade
it seems that there is no way, Chosen does not expose anything for you to change from outside (at least by the code that is in your jsfiddle).
– bfavaretto