Skip to content
This repository

Added support for multiple events at the same time. #25

Open
wants to merge 2 commits into from

2 participants

Vincent Petry richardjohnjensen
Vincent Petry

Before this fix, pasting text into a field with the mouse (right click +
paste) didn't trigger the event.
Some other plugins like clearableTextField
(https://github.com/ono/clearable_text_field/) only trigger the "change"
event which didn't refresh the search.

added some commits
Added support for multiple events at the same time.
Before this fix, pasting text into a field with the mouse (right click +
paste) didn't trigger the event.
Some other plugins like clearableTextField
(https://github.com/ono/clearable_text_field/) only trigger the "change"
event which didn't refresh the search.
50e09f9
A shorter version of the event binding code. 898db2b
richardjohnjensen

Using your patch and the latest clearable_text_field, I can paste into the selector to trigger the quicksearch. Cool!
Did you have to modify the clearable_text_field to remove the quicksearch filter?

I was looking for a solution when I ran against your pull using the same components, but cannot get the clear text to reset the search.

Vincent Petry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Jun 30, 2011
Added support for multiple events at the same time.
Before this fix, pasting text into a field with the mouse (right click +
paste) didn't trigger the event.
Some other plugins like clearableTextField
(https://github.com/ono/clearable_text_field/) only trigger the "change"
event which didn't refresh the search.
50e09f9
A shorter version of the event binding code. 898db2b
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 16 additions and 11 deletions. Show diff stats Hide diff stats

  1. 27  jquery.quicksearch.js
27  jquery.quicksearch.js
@@ -7,7 +7,7 @@
7 7
 			stripeRows: null,
8 8
 			loader: null,
9 9
 			noResults: '',
10  
-			bind: 'keyup',
  10
+			bind: 'keyup input mouseup change',
11 11
 			onBefore: function () { 
12 12
 				return;
13 13
 			},
@@ -109,13 +109,12 @@
109 109
 				jq_results = jq_results.not(options.noResults);
110 110
 			}
111 111
 			
112  
-			var t = (typeof options.selector === "string") ? jq_results.find(options.selector) : $(target).not(options.noResults);
113  
-			cache = t.map(function () {
114  
-				return e.strip_html(this.innerHTML);
115  
-			});
  112
+			cache = [];
  113
+			rowcache = [];
116 114
 			
117  
-			rowcache = jq_results.map(function () {
118  
-				return this;
  115
+			jq_results.each(function () {
  116
+				rowcache.push(this);
  117
+				cache.push($(this).find(options.selector).text());
119 118
 			});
120 119
 			
121 120
 			return this.go();
@@ -139,12 +138,18 @@
139 138
 		this.loader(false);
140 139
 		
141 140
 		return this.each(function () {
142  
-			$(this).bind(options.bind, function () {
  141
+			var self = $(this);
  142
+			var handler = function (event) {
  143
+				var oldVal = val;
143 144
 				val = $(this).val();
144  
-				e.trigger();
145  
-			});
  145
+				if ( oldVal != val ) {
  146
+					e.trigger();
  147
+				}
  148
+			};
  149
+			
  150
+			self.bind(options.bind, handler);
146 151
 		});
147 152
 		
148 153
 	};
149 154
 
150  
-}(jQuery, this, document));
  155
+}(jQuery, this, document));
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.