diff options
author | Felix Nagel <info@felixnagel.com> | 2011-09-27 21:15:47 +0200 |
---|---|---|
committer | Felix Nagel <info@felixnagel.com> | 2011-09-27 21:33:08 +0200 |
commit | 426ecaf21e4e29b3025ddeddb3b774e29fc47bc9 (patch) | |
tree | 75f7f19f16f440d8b0da3071705b5c70ac82417b /ui | |
parent | 7e8e542667947674f3922e1af8801c9b3030217a (diff) | |
download | jquery-ui-426ecaf21e4e29b3025ddeddb3b774e29fc47bc9.tar.gz jquery-ui-426ecaf21e4e29b3025ddeddb3b774e29fc47bc9.zip |
Selectmenu: implemented change callback event
Diffstat (limited to 'ui')
-rw-r--r-- | ui/jquery.ui.selectmenu.js | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/ui/jquery.ui.selectmenu.js b/ui/jquery.ui.selectmenu.js index 6d15dfa6f..4cb72ae57 100644 --- a/ui/jquery.ui.selectmenu.js +++ b/ui/jquery.ui.selectmenu.js @@ -60,8 +60,8 @@ $.widget( "ui.selectmenu", { self.element.bind( 'click.selectmenu', function() { self.newelement.focus(); return false; - }); - // .hide(); + }) + .hide(); // create button self.newelement = $( '<a />', { @@ -153,7 +153,8 @@ $.widget( "ui.selectmenu", { }); }, - refresh: function() { + // TODO update the value option + refresh: function() { var self = this, options = this.options; @@ -179,15 +180,21 @@ $.widget( "ui.selectmenu", { .data( 'element.selectelemenu', self.element ) .menu({ select: function( event, ui ) { - var item = ui.item.data( "item.selectmenu" ); + var flag = false, + item = ui.item.data( "item.selectmenu" ); + + if ( item.index != self.element[0].selectedIndex ) flag = true; + self._setSelected( event, item ); - item.element = $ ( self.items[ item.index ] ); + item.element = self.items[ item.index ]; self._trigger( "select", event, { item: item } ); + self.close( event, true); + + if ( flag ) self._trigger( "change", event, { item: item } ); }, focus: function( event, ui ) { - var item = ui.item.data( "item.selectmenu" ); - self._trigger( "focus", event, { item: item } ); + self._trigger( "focus", event, { item: ui.item.data( "item.selectmenu" ) } ); } }) .bind({ |