diff options
author | Ian <solidmoose@users.noreply.github.com> | 2016-09-21 11:50:47 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-21 11:50:47 -0700 |
commit | 4083c0ee9f22b1fcf87e76cdef254a96ed0748c8 (patch) | |
tree | 86bb32e7587cf7c9d102d641fbb4542bb5ee65da /js/jquery.multi-select.js | |
parent | b5e268a27c8c0a1da068bb5dbaa18ee6aa92c577 (diff) | |
download | multi-select-4083c0ee9f22b1fcf87e76cdef254a96ed0748c8.zip multi-select-4083c0ee9f22b1fcf87e76cdef254a96ed0748c8.tar.gz multi-select-4083c0ee9f22b1fcf87e76cdef254a96ed0748c8.tar.bz2 |
Fix addOption when 'nested' specified
Tidied up code (realized the logic was already there, just out of order).
Diffstat (limited to 'js/jquery.multi-select.js')
-rw-r--r-- | js/jquery.multi-select.js | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/js/jquery.multi-select.js b/js/jquery.multi-select.js index c653dd3..488b9ca 100644 --- a/js/jquery.multi-select.js +++ b/js/jquery.multi-select.js @@ -182,17 +182,7 @@ that.$element.find("option[value='"+option.value+"']").length === 0){ var $option = $('<option value="'+option.value+'">'+option.text+'</option>'), $container = option.nested === undefined ? that.$element : $("optgroup[label='"+option.nested+"']"), - index; - - if(typeof option.index === 'undefined'){ - if(typeof option.nested !== 'undefined' && option.nested !== null){ - index = that.$element.children('[label="' + option.nested + '"]').children().length; - } else { - index = that.$element.children().length; - } - } else { - index = parseInt(option.index); - } + index = parseInt((typeof option.index === 'undefined' ? $container.children().length : option.index)); $option.insertAt(index, $container); that.generateLisFromOption($option.get(0), index, option.nested); |