File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 45
45
$second . val ( value ) . change ( ) ;
46
46
} ;
47
47
48
+ /** Helper Function to remove childs from second */
48
49
var removeValues = function ( ) {
49
50
$ ( $secondid + " option" ) . remove ( ) ;
50
51
} ;
51
52
52
- $ ( this ) . change ( function ( ) {
53
+ /** OnChange Handler */
54
+ $ ( this ) . change ( function ( ) {
53
55
removeValues ( ) ;
54
56
var $current = this . options [ this . selectedIndex ] . value ;
55
57
if ( $current !== '' ) {
78
80
}
79
81
) ;
80
82
}
81
- o . appendTo ( $second ) ;
83
+ if ( k === bestk ) { o . html ( k ) . attr ( "selected" , "selected" ) ; }
84
+ o . appendTo ( $second ) ;
82
85
} ) ;
83
86
}
84
87
} ) ;
89
92
} ) ;
90
93
91
94
return this . each ( function ( ) {
95
+
96
+ //remove all current items in select boxes
92
97
$first . children ( ) . remove ( ) ;
93
98
$second . children ( ) . remove ( ) ;
94
99
100
+ // Handle the empty option param
95
101
if ( options . emptyOption ) {
96
102
var oe = $ ( "<option>" ) . html ( options . emptyValue ) . attr ( 'value' , options . emptyKey ) ;
97
103
oe . appendTo ( $first ) ;
98
104
}
99
105
106
+ // add all options to first select box
100
107
$ . each ( values ,
101
108
function ( k , v ) {
102
109
var of = $ ( "<option>" ) . html ( k ) . attr ( 'value' , v . key ) ;
You can’t perform that action at this time.
0 commit comments