mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Selectmenu: implemented change callback event
This commit is contained in:
parent
7e8e542667
commit
426ecaf21e
21
ui/jquery.ui.selectmenu.js
vendored
21
ui/jquery.ui.selectmenu.js
vendored
@ -60,8 +60,8 @@ $.widget( "ui.selectmenu", {
|
|||||||
self.element.bind( 'click.selectmenu', function() {
|
self.element.bind( 'click.selectmenu', function() {
|
||||||
self.newelement.focus();
|
self.newelement.focus();
|
||||||
return false;
|
return false;
|
||||||
});
|
})
|
||||||
// .hide();
|
.hide();
|
||||||
|
|
||||||
// create button
|
// create button
|
||||||
self.newelement = $( '<a />', {
|
self.newelement = $( '<a />', {
|
||||||
@ -153,7 +153,8 @@ $.widget( "ui.selectmenu", {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
refresh: function() {
|
// TODO update the value option
|
||||||
|
refresh: function() {
|
||||||
var self = this,
|
var self = this,
|
||||||
options = this.options;
|
options = this.options;
|
||||||
|
|
||||||
@ -179,15 +180,21 @@ $.widget( "ui.selectmenu", {
|
|||||||
.data( 'element.selectelemenu', self.element )
|
.data( 'element.selectelemenu', self.element )
|
||||||
.menu({
|
.menu({
|
||||||
select: function( event, ui ) {
|
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 );
|
self._setSelected( event, item );
|
||||||
item.element = $ ( self.items[ item.index ] );
|
item.element = self.items[ item.index ];
|
||||||
self._trigger( "select", event, { item: item } );
|
self._trigger( "select", event, { item: item } );
|
||||||
|
|
||||||
self.close( event, true);
|
self.close( event, true);
|
||||||
|
|
||||||
|
if ( flag ) self._trigger( "change", event, { item: item } );
|
||||||
},
|
},
|
||||||
focus: function( event, ui ) {
|
focus: function( event, ui ) {
|
||||||
var item = ui.item.data( "item.selectmenu" );
|
self._trigger( "focus", event, { item: ui.item.data( "item.selectmenu" ) } );
|
||||||
self._trigger( "focus", event, { item: item } );
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.bind({
|
.bind({
|
||||||
|
Loading…
Reference in New Issue
Block a user