Simulate browser behavior for selecting first dropdown element in non-multiselect, if no elements are selected by default. props koopersmith. fixes #16190
git-svn-id: https://develop.svn.wordpress.org/trunk@17252 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
e1b27b6bd9
commit
733f374f85
@ -14,15 +14,33 @@ window.listTable = {
|
||||
this.$tbody = $('#the-list, #the-comment-list');
|
||||
},
|
||||
|
||||
/**
|
||||
* Simulates form.reset() for all input, select, and textarea elements
|
||||
* within a provided context.
|
||||
*/
|
||||
reset: function( context ) {
|
||||
context = $( context );
|
||||
context = $(context);
|
||||
|
||||
$('input', context).each( function(){
|
||||
this.value = this.defaultValue;
|
||||
this.checked = this.defaultChecked;
|
||||
});
|
||||
$('option', context).each( function(){
|
||||
|
||||
$('select', context).each( function(){
|
||||
var options = $('option', this),
|
||||
anySelected = false;
|
||||
|
||||
options.each( function(){
|
||||
this.selected = this.defaultSelected;
|
||||
anySelected = anySelected || this.defaultSelected;
|
||||
});
|
||||
|
||||
// If no options are selected within a single-select dropdown,
|
||||
// select the first element by default.
|
||||
if ( ! this.multiple && ! anySelected )
|
||||
options[0].selected = true;
|
||||
});
|
||||
|
||||
$('textarea', context).each( function(){
|
||||
this.value = this.defaultValue;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user