Reputation: 2894
I'm using this plugin
http://harvesthq.github.com/chosen/
and I have an specific problem when I search some options with blanks. for example I have an option tha is "Antigua y barbuda" if I type :
it only fails when I start writing not the first word (only in cases that has blanks)
Regex:
regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
Upvotes: 0
Views: 1919
Reputation: 51
For Joomla developers with similar issues:
JHtml::_('formbehavior.chosen', 'select', null, array('search_contains' => true));
Upvotes: 1
Reputation:
You don't need to remove \s just set search_contains: true
$(".chzn-select").chosen({search_contains: true});
Upvotes: 2
Reputation: 2894
Solved it removing "\s"
zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&"), 'i');
Upvotes: 1
Reputation: 21676
This is might be a Chosen problem. Try using Select2 plugin, which originate from Chosen and its much better. Plus it allows custom matcher function so you can resolve your problem manually.
Upvotes: 4