Skip to content
Browse files

Fix Elect 0.9.4

  • Loading branch information...
1 parent 978d40f commit 8c8f839583faea107838ed809995102a408941e2 Noah Burney committed
Showing with 21 additions and 1 deletion.
  1. +21 −1 lib/jquery.elect-0.9.4.js
View
22 lib/jquery.elect-0.9.4.js
@@ -69,7 +69,13 @@ module('lib.jquery.elect',
// scope
var kore = this;
// Add click event to <span>
- this.span.mousedown(function(e){ e.preventDefault(); e.stopPropagation(); kore.open(e); kore.focus(e); });
+ this.span.mousedown(function(e){
+ e.preventDefault(); e.stopPropagation();
+ kore.open(e); kore.focus(e);
+ });
+
+ this.el.change(function(e){ kore.el_change.call(kore, e); });
+
this.span.mouseup(function(e){ e.preventDefault(); e.stopPropagation(); return false;})
$('input, select, textarea, button').focus(function(e){ kore.blur(e); });
// Hook in to fokus's focus event
@@ -230,6 +236,20 @@ module('lib.jquery.elect',
this.el.children('option').removeAttr('selected');
this.el.children('option:eq('+this.selected+')').attr('selected','selected');
},
+
+ // Fired whenever the actual <select>'s change event fires
+ // to ensure consistency
+ el_change: function(e){
+ var num = 0,
+ ops = this.el.children('option'),
+ val = this.el.val();
+ ops.each(function(i, tem){
+ num = i;
+ if ( $(tem).attr('value') === val ) return false;
+ });
+
+ if ( num !== this.selected ) this.select(num);
+ },
// Changes the <span> and <li> and this.selected
// to reflect new selected option

0 comments on commit 8c8f839

Please sign in to comment.
Something went wrong with that request. Please try again.