Skip to content

Commit

Permalink
Fix Elect 0.9.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Noah Burney committed Feb 2, 2010
1 parent 978d40f commit 8c8f839
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion lib/jquery.elect-0.9.4.js
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8c8f839

Please sign in to comment.