Javascript 搜索是否匹配并忽略大写和空格
我为我的应用程序构建了一个使用搜索框的过滤。我有一个问题,每次我键入大写字母或添加空格时,搜索框过滤都不会发生。我希望能够过滤,无论环境如何。如果字符是匹配的“已筛选”Javascript 搜索是否匹配并忽略大写和空格,javascript,ember.js,Javascript,Ember.js,我为我的应用程序构建了一个使用搜索框的过滤。我有一个问题,每次我键入大写字母或添加空格时,搜索框过滤都不会发生。我希望能够过滤,无论环境如何。如果字符是匹配的“已筛选” {{input type="search" value=theFilter placeholder="ID, group name..."}} theFilter: null, filterHotel: function() { var model = this.get('model'); var th
{{input type="search" value=theFilter placeholder="ID, group name..."}}
theFilter: null,
filterHotel: function() {
var model = this.get('model');
var theFilter = this.get('theFilter');
return model.filter(function(hotelRequest){
return (hotelRequest.get('inquiry.name') && hotelRequest.get('inquiry.name').search(theFilter) != -1)
|| (hotelRequest.get('inquiry.id') == theFilter);
});
}.property('theFilter'),
您需要查找trim()和toLowerCase(),然后尝试
var theFilter=this.get('theFilter')。toLowerCase().trim()代码>谢谢你们解决了可能重复的问题