|
147 | 147 | config = {}; |
148 | 148 | } |
149 | 149 | this.messageFor = bind(this.messageFor, this); |
150 | | - this.elements = bind(this.elements, this); |
| 150 | + this.elementsFor = bind(this.elementsFor, this); |
151 | 151 | this.resetElement = bind(this.resetElement, this); |
152 | 152 | this.reset = bind(this.reset, this); |
153 | 153 | this.validateElement = bind(this.validateElement, this); |
|
170 | 170 | }; |
171 | 171 |
|
172 | 172 | InputValidator.prototype.prepareElements = function(context) { |
173 | | - var $elements; |
| 173 | + var $elements, ns; |
174 | 174 | if (context == null) { |
175 | 175 | context = null; |
176 | 176 | } |
177 | 177 | if (context == null) { |
178 | 178 | context = this.context; |
179 | 179 | } |
180 | | - $elements = this.elements(context); |
| 180 | + ns = 'inputvalidator'; |
| 181 | + $elements = this.elementsFor(context); |
181 | 182 | if (this.config.validateOnFocusOut) { |
182 | | - $elements.focusout((function(_this) { |
| 183 | + $elements.off("focusout." + ns).on("focusout." + ns, (function(_this) { |
183 | 184 | return function(e) { |
184 | 185 | return _this.validateElement(e.target); |
185 | 186 | }; |
186 | 187 | })(this)); |
187 | 188 | } |
188 | 189 | if (this.config.removeHintOnFocus) { |
189 | | - $elements.focus((function(_this) { |
| 190 | + $elements.off("focus." + ns).on("focus." + ns, (function(_this) { |
190 | 191 | return function(e) { |
191 | 192 | return _this.resetElement(e.target); |
192 | 193 | }; |
193 | 194 | })(this)); |
194 | 195 | } |
195 | 196 | if (this.config.validateOnKeyUp) { |
196 | | - $elements.keyup((function(_this) { |
| 197 | + $elements.off("keyup." + ns).on("keyup." + ns, (function(_this) { |
197 | 198 | return function(e) { |
198 | 199 | if ($(e.target).data('invalid')) { |
199 | 200 | return _this.validateElement(e.target); |
|
202 | 203 | })(this)); |
203 | 204 | } |
204 | 205 | if (this.config.validateOnClick) { |
205 | | - return $elements.click((function(_this) { |
| 206 | + return $elements.off("click." + ns).on("click." + ns, (function(_this) { |
206 | 207 | return function(e) { |
207 | 208 | return _this.validateElement(e.target); |
208 | 209 | }; |
|
216 | 217 | context = null; |
217 | 218 | } |
218 | 219 | errors = []; |
219 | | - $elements = this.elements(context); |
| 220 | + $elements = this.elementsFor(context); |
220 | 221 | ref = $elements.get(); |
221 | 222 | for (i = 0, len = ref.length; i < len; i++) { |
222 | 223 | element = ref[i]; |
|
259 | 260 | if (context == null) { |
260 | 261 | context = null; |
261 | 262 | } |
262 | | - return this.resetElement(this.elements(context)); |
| 263 | + return this.resetElement(this.elementsFor(context)); |
263 | 264 | }; |
264 | 265 |
|
265 | 266 | InputValidator.prototype.resetElement = function($element) { |
266 | 267 | return this.config.handler.onResetIntern(this, $element); |
267 | 268 | }; |
268 | 269 |
|
269 | | - InputValidator.prototype.elements = function(context) { |
| 270 | + InputValidator.prototype.elementsFor = function(context) { |
270 | 271 | if (context == null) { |
271 | 272 | context = null; |
272 | 273 | } |
|
0 commit comments