Skip to content

Commit 1e50ca7

Browse files
committed
Merge pull request marcj#79 from tomlion/master
fix the bug that breaks the setValue method in IE9, IE9's behavior is different with previous version
2 parents f90c398 + aea081e commit 1e50ca7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

jquery.selectBox.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,11 @@ if(jQuery) (function($) {
744744
var setValue = function(select, value) {
745745
select = $(select);
746746
select.val(value);
747-
value = select.val();
747+
value = select.val(); // IE9's select would be null if it was set with a non-exist options value
748+
if(value == null) { // So check it here and set it with the first option's value if possible
749+
value = select.children().first().val();
750+
select.val(value);
751+
}
748752
var control = select.data('selectBox-control');
749753
if( !control ) return;
750754
var settings = select.data('selectBox-settings'),

0 commit comments

Comments
 (0)