mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
parent
4e13860067
commit
39853fda45
@ -329,4 +329,22 @@ $.each( [
|
||||
} );
|
||||
} );
|
||||
|
||||
asyncTest( "Selectmenu should reset when its parent form resets", function() {
|
||||
expect( 2 );
|
||||
|
||||
var element = $( "#speed" ).selectmenu(),
|
||||
widget = element.selectmenu( "widget" ),
|
||||
initialValue = element.val(),
|
||||
form = element.closest( "form" );
|
||||
|
||||
element.val( "Slower" );
|
||||
element.selectmenu( "refresh" );
|
||||
equal( $.trim( widget.text() ), "Slower" );
|
||||
form[ 0 ].reset();
|
||||
setTimeout( function() {
|
||||
equal( $.trim( widget.text() ), initialValue );
|
||||
start();
|
||||
} );
|
||||
} );
|
||||
|
||||
} );
|
||||
|
@ -13,7 +13,7 @@
|
||||
<div id="qunit-fixture">
|
||||
<div id="selectmenu-wrap1" class="selectmenu-wrap"></div>
|
||||
|
||||
<div id="selectmenu-wrap2" class="selectmenu-wrap">
|
||||
<form id="selectmenu-wrap2" class="selectmenu-wrap">
|
||||
<label for="speed">Select a speed:</label>
|
||||
<select name="speed" id="speed">
|
||||
<option value="Slower">Slower</option>
|
||||
@ -22,7 +22,7 @@
|
||||
<option value="Fast">Fast</option>
|
||||
<option value="Faster">Faster</option>
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<label for="number">Select a number:</label>
|
||||
<select name="number" id="number">
|
||||
|
@ -24,6 +24,7 @@
|
||||
"jquery",
|
||||
"./menu",
|
||||
"../escape-selector",
|
||||
"../form-reset-mixin",
|
||||
"../keycode",
|
||||
"../labels",
|
||||
"../position",
|
||||
@ -38,7 +39,7 @@
|
||||
}
|
||||
}( function( $ ) {
|
||||
|
||||
return $.widget( "ui.selectmenu", {
|
||||
return $.widget( "ui.selectmenu", [ $.ui.formResetMixin, {
|
||||
version: "@VERSION",
|
||||
defaultElement: "<select>",
|
||||
options: {
|
||||
@ -76,6 +77,7 @@ return $.widget( "ui.selectmenu", {
|
||||
|
||||
this._drawButton();
|
||||
this._drawMenu();
|
||||
this._bindFormResetHandler();
|
||||
|
||||
this._rendered = false;
|
||||
this.menuItems = $();
|
||||
@ -675,12 +677,13 @@ return $.widget( "ui.selectmenu", {
|
||||
},
|
||||
|
||||
_destroy: function() {
|
||||
this._unbindFormResetHandler();
|
||||
this.menuWrap.remove();
|
||||
this.button.remove();
|
||||
this.element.show();
|
||||
this.element.removeUniqueId();
|
||||
this.labels.attr( "for", this.ids.element );
|
||||
}
|
||||
} );
|
||||
} ] );
|
||||
|
||||
} ) );
|
||||
|
Loading…
Reference in New Issue
Block a user