Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Can search on all columns except number type columns.
- Loading branch information
1 parent
28d683a
commit 933be1d
Showing
4 changed files
with
26 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
Template.itemsearch.events({ | ||
'keyup .searchInput': _.throttle(function(e, t) { | ||
Session.set('searchQuery', {name: t.$('.searchInput').val()}); | ||
var searchQuery = Session.get('searchQuery') || {}; | ||
searchQuery[this.columnName] = t.$('.searchInput').val(); | ||
Session.set('searchQuery', searchQuery); | ||
},500) | ||
}); | ||
|
||
Template.itemsearch.rendered=function(){ | ||
var searchQuery = Session.get('searchQuery') || {}; | ||
var searchColumnValue = searchQuery[this.data.columnName] || ''; | ||
|
||
this.$('.searchInput').val(searchColumnValue); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
Meteor.publish("allItems", function (searchQuery) { | ||
var mongoQuery = {}; | ||
_.each(_.keys(searchQuery), function(key){ | ||
mongoQuery[key] = {$regex: searchQuery[key], $options: 'i'}; | ||
}); | ||
if(searchQuery){ | ||
_.each(_.keys(searchQuery), function(key){ | ||
mongoQuery[key] = {$regex: searchQuery[key], $options: 'i'}; | ||
}); | ||
} | ||
|
||
return Items.find(mongoQuery,{limit:10}); | ||
}); |