diff options
author | Pedro Medeiros <pedrosnk@gmail.com> | 2015-03-23 13:03:16 -0300 |
---|---|---|
committer | Pedro Medeiros <pedrosnk@gmail.com> | 2015-03-23 13:03:16 -0300 |
commit | 2bb46dd5d0ae3afac9371a2ac16cca67849dd64c (patch) | |
tree | 249fb27cb6fe86ef57c96b4ff155e35a6f6a0e5d /js | |
parent | 8712b029b6964c79dfa5d7048d39a00a06e06033 (diff) | |
download | multi-select-2bb46dd5d0ae3afac9371a2ac16cca67849dd64c.zip multi-select-2bb46dd5d0ae3afac9371a2ac16cca67849dd64c.tar.gz multi-select-2bb46dd5d0ae3afac9371a2ac16cca67849dd64c.tar.bz2 |
add conditional so the component can accepts value that is interpreted to false
Diffstat (limited to 'js')
-rw-r--r-- | js/jquery.multi-select.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/js/jquery.multi-select.js b/js/jquery.multi-select.js index 697d15b..1772630 100644 --- a/js/jquery.multi-select.js +++ b/js/jquery.multi-select.js @@ -174,9 +174,12 @@ 'addOption' : function(options){ var that = this; - if (options.value) options = [options]; + if (options.value !== undefined && options.value !== null){ + options = [options]; + } $.each(options, function(index, option){ - if (option.value && that.$element.find("option[value='"+option.value+"']").length === 0){ + if (option.value !== undefined && option.value !== null && + that.$element.find("option[value='"+option.value+"']").length === 0){ var $option = $('<option value="'+option.value+'">'+option.text+'</option>'), index = parseInt((typeof option.index === 'undefined' ? that.$element.children().length : option.index)), $container = option.nested == undefined ? that.$element : $("optgroup[label='"+option.nested+"']") |