Browse files

apply focus() and blur() to all elements in collection

This ensures that a focused element gets blurred even if it's not the
first element in the collection.

Closes #543
  • Loading branch information...
1 parent 86fb735 commit 85c8a849f60e68bd983f8e58ac98ee6f5260def7 @juhovh juhovh committed with mislav Jul 6, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 src/event.js
View
5 src/event.js
@@ -210,7 +210,10 @@
;['focus', 'blur'].forEach(function(name) {
$.fn[name] = function(callback) {
if (callback) this.bind(name, callback)
- else if (this.length) try { this.get(0)[name]() } catch(e){}
+ else this.each(function(){
+ try { this[name]() }
+ catch(e) {}
+ })
return this
}
})

0 comments on commit 85c8a84

Please sign in to comment.