MCPcopy
hub / github.com/Robdel12/DropKick / reset

Method reset

src/dropkick.js:702–720  ·  view source on GitHub ↗

* 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 )

Source from the content-addressed store, hash-verified

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

Callers 5

selectOneMethod · 0.95
handleEventMethod · 0.95
_delegateMethod · 0.95
_keyHandlerMethod · 0.95
dropkick-test.jsFile · 0.80

Calls 1

selectMethod · 0.95

Tested by

no test coverage detected