r2770 - refactored the _closeOthers method
Author: scottjehl
Date: Mon Jun 15 09:46:39 2009
New Revision: 2770
Modified:
branches/labs/selectmenu/ui.selectmenu.js
Log:
refactored the _closeOthers method
Modified: branches/labs/selectmenu/ui.selectmenu.js
==============================================================================
--- branches/labs/selectmenu/ui.selectmenu.js (original)
+++ branches/labs/selectmenu/ui.selectmenu.js Mon Jun 15 09:46:39 2009
@@ -25,6 +25,8 @@
var tabindex = this.element.attr('tabindex') || '0';
this.newelement.attr('tabindex', tabindex);
+ //save reference to select in data for ease in calling methods
+ this.newelement.data('selectelement', this.element);
//menu icon
this.selectmenuIcon = $('<span class="ui-selectmenu-icon
ui-icon"></span>')
@@ -43,7 +45,6 @@
//click toggle for menu visibility
this.newelement
.bind('mousedown', function(){
- self._closeOthers();
self._toggle();
//make sure a click won't open/close instantly
if(o.style == "popup"){
@@ -61,7 +62,6 @@
case $.ui.keyCode.ENTER:
case $.ui.keyCode.SPACE:
ret = false;
- self._closeOthers();
self._toggle();
break;
case $.ui.keyCode.UP:
@@ -290,17 +290,18 @@
},
_closeOthers: function(){
- //this needs to be handled better
-
$('.ui-selectmenu-open').not(this.list).removeClass('ui-selectmenu-open');
- $('.ui-select').not(this.newelement).trigger('blur');
+ $('.ui-selectmenu.ui-state-active').not(this.newelement).each(function(){
+ $(this).data('selectelement').selectmenu('close');
+ })
},
_genId: function(type){
var num = Math.round(Math.random() * 1000);
return [this.element.attr('id') + '_' + 'button' + '_' + num,
this.element.attr('id') + '_' + 'menu' + '_' + num];
},
-
+
open: function(){
+ this._closeOthers();
this._refreshPosition();
this.newelement.addClass('ui-state-active');
this.list
@@ -317,7 +318,6 @@
this.list.removeClass('ui-selectmenu-open');
if(this.options.style == "dropdown"){
this.newelement.removeClass('ui-corner-top').addClass('ui-corner-all'); }
if(retainFocus){this.newelement.focus();}
- else{ this.newelement.blur(); }
return this.element;
},