Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #932 from BenjaminNeilDavis/issue-931-search-clear…
Browse files Browse the repository at this point in the history
…ed-event

search's cleared event is fired when field is empty #931
  • Loading branch information
Stephen Williams committed Jan 5, 2015
2 parents 83fafc2 + 78dd9af commit 208d722
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,21 @@
if (e.which === 13) {
e.preventDefault();
this.action();
} else {
}
else if (e.which === 9) {
e.preventDefault();
}
else {
val = this.$input.val();
if(!val){
this.clear();
}else if(val!==this.activeSearch){

if(val!==this.activeSearch){
this.$icon.removeClass(remove).addClass(search);
if(val) {
this.$element.removeClass('searched');
}
else if (this.options.clearOnEmpty){
this.clear();
}
}else{
this.$icon.removeClass(search).addClass(remove);
}
Expand Down Expand Up @@ -156,7 +165,9 @@
return ( methodReturn === undefined ) ? $set : methodReturn;
};

$.fn.search.defaults = {};
$.fn.search.defaults = {
clearOnEmpty: false
};

$.fn.search.Constructor = Search;

Expand Down

0 comments on commit 208d722

Please sign in to comment.