* Resets the Dropkick and select to it's original selected options; if `clear` is `true`, * It will select the first option by default (or no options for multi-selects). * * @method reset * @param {Boolean} clear Defaults to first option if true * @example * var select = new Dropk
( clear )
| 700 | * select.reset(true); |
| 701 | */ |
| 702 | reset( clear ) { |
| 703 | var i, |
| 704 | select = this.data.select; |
| 705 | |
| 706 | this.selectedOptions.length = 0; |
| 707 | |
| 708 | for ( i = 0; i < select.options.length; i++ ) { |
| 709 | select.options[ i ].selected = false; |
| 710 | _.removeClass( this.options[ i ], "dk-option-selected" ); |
| 711 | this.options[ i ].setAttribute( "aria-selected", "false" ); |
| 712 | if ( !clear && select.options[ i ].defaultSelected ) { |
| 713 | this.select( i, true ); |
| 714 | } |
| 715 | } |
| 716 | |
| 717 | if ( !this.selectedOptions.length && !this.multiple ) { |
| 718 | this.select( 0, true ); |
| 719 | } |
| 720 | } |
| 721 | |
| 722 | /** |
| 723 | * Rebuilds the DK Object |
no test coverage detected