{"action":"opened","issue":{"url":"https://api.github.com/repos/davidstutz/bootstrap-multiselect/issues/469","labels_url":"https://api.github.com/repos/davidstutz/bootstrap-multiselect/issues/469/labels{/name}","comments_url":"https://api.github.com/repos/davidstutz/bootstrap-multiselect/issues/469/comments","events_url":"https://api.github.com/repos/davidstutz/bootstrap-multiselect/issues/469/events","html_url":"https://github.com/davidstutz/bootstrap-multiselect/issues/469","id":54341838,"number":469,"title":"function(dataprovider) does not handle needed attributes correctly - text and disabled missing","user":{"login":"landreww","id":6261643,"avatar_url":"https://avatars.githubusercontent.com/u/6261643?v=3","gravatar_id":"","url":"https://api.github.com/users/landreww","html_url":"https://github.com/landreww","followers_url":"https://api.github.com/users/landreww/followers","following_url":"https://api.github.com/users/landreww/following{/other_user}","gists_url":"https://api.github.com/users/landreww/gists{/gist_id}","starred_url":"https://api.github.com/users/landreww/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/landreww/subscriptions","organizations_url":"https://api.github.com/users/landreww/orgs","repos_url":"https://api.github.com/users/landreww/repos","events_url":"https://api.github.com/users/landreww/events{/privacy}","received_events_url":"https://api.github.com/users/landreww/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-14T16:22:20Z","updated_at":"2015-01-14T16:22:20Z","closed_at":null,"body":"When reading options from an array the code (beginning at line 1074) is missing two attributes, text and disabled.  I would also submit that the code should not presuppose the desire of the data provider to want the label attribute to be set with contents of the value attribute (should the label be omitted). The definition of the label attribute indicates that if omitted, it should contain the 'text' value (done in the browser).   In addition, Firefox requires the text attribute as it will not display the label.  \r\n If anything (although I would argue against it), if the text value is omitted, it should be set to the label (if exists and value exists) or to the value (if exists and no label supplied).\r\n\r\nAlso, the disabled attribute is missing as it is a proper attribute in both the optiongroup and option tags.\r\n\r\nHere is my suggested correction:\r\n                if ($.isArray(option.children)) { // create optiongroup tag\r\n                    groupCounter++;\r\n                    tag = $('<optgroup/>').attr({\r\n                        label: option.label || 'Group ' + groupCounter,\r\n                        disabled: !!option.disabled\r\n                    });\r\n                    forEach(option.children, function(subOption) { // add children option tags\r\n                        tag.append($('<option/>').attr({\r\n                            value: subOption.value,\r\n                            label: subOption.label,\r\n                            title: subOption.title,\r\n                            selected: !!subOption.selected,\r\n                            disabled: !!subOption.disabled\r\n                        }).text(subOption.text));\r\n                    });\r\n\r\n                    optionDOM += '</optgroup>';\r\n                }\r\n                else { // create option tag\r\n                    tag = $('<option/>').attr({\r\n                        value: option.value,\r\n                        label: option.label,\r\n                        title: option.title,\r\n                        selected: !!option.selected,\r\n                        disabled: !!option.disabled\r\n                    }).text(option.text);\r\n                }\r\n\r\nThe data used for my testing was as follows:\r\n\t var optgroups = [\r\n\t\t{\r\n\t\t\t\r\n\t\t\tlabel: 'Dade', disabled: 'disabled', children: [\r\n\t\t\t\t{label: 'Miami', value: 'Miami'},\r\n\t\t\t\t{label: 'HollyWood', value: 'Hollywood', title: 'this is a group'}\r\n\t\t\t]\r\n\t\t},\r\n\t\t{\r\n\t\t\tlabel: 'West Central', children: [\r\n\t\t\t\t{label: 'This is the label - no value', text: 'This is text - no value', selected: 'selected'},\r\n\t\t\t\t{label: 'This is the label - no text', value: 'this is value - no text', selected: 'selected'},\t\t\t\t\r\n\t\t\t\t{value: 'this is the value - no label', text: 'this is the text - no label', selected: 'selected'},\t\t\t\t\r\n\t\t\t\t{value: 'this is the value - no label - no text', selected: 'selected'},\t\t\t\t\r\n\t\t\t\t{label: 'This is the label - no value - no text', selected: 'selected'},\t\t\t\t\r\n\t\t\t\t{text: 'this is the text - no label - no value', selected: 'selected'},\r\n\t\t\t\t{label: 'This is the label', value: 'this is the value', title: 'this is the title', text: 'This is text', selected: 'selected'},\r\n\t\t\t\t{label: 'This is the label - no text', text: 'this is text - no value', selected: 'selected'}\t\t\t\t\r\n\t\t\t]\r\n\t\t}\r\n\t];\r\n\r\nThis was the resulting selection group in Firefox (as I previously said, IE11 will show the label if no text is supplied):\r\n<select id=\"CityList\" class=\"multiselect form-control\" name=\"CityList[]\" multiple=\"multiple\" style=\"display: none;\">\r\n\t<optgroup label=\"Dade\" disabled=\"disabled\">\r\n\t\t<option value=\"Miami\" label=\"Miami\"></option>\r\n\t\t<option value=\"Hollywood\" label=\"HollyWood\" title=\"this is a group\"></option>\r\n\t</optgroup>\r\n\t<optgroup label=\"West Central\">\r\n\t\t<option label=\"This is the label - no value\" selected=\"selected\">This is text - no value</option> <== LABEL IS DISPLAYED IN LIST\r\n\t\t<option value=\"this is value - no text\" label=\"This is the label - no text\" selected=\"selected\"></option> <== LABEL IS DISPLAYED IN LIST\r\n\t\t<option value=\"this is the value - no label\" selected=\"selected\">this is the text - no label</option> <== TEXT IS DISPLAYED IN LIST\r\n\t\t<option value=\"this is the value - no label - no text\" selected=\"selected\"></option> <== BLANK DISPLAYED IN LIST\r\n\t\t<option label=\"This is the label - no value - no text\" selected=\"selected\"></option> <== LABEL IS DISPLAYED IN LIST\r\n\t\t<option selected=\"selected\">this is the text - no label - no value</option> <== TEXT IS DISPLAYED IN LIST\r\n\t\t<option value=\"this is the value\" label=\"This is the label\" title=\"this is the title\" selected=\"selected\">This is text</option> <== LABEL IS DISPLAYED IN LIST\r\n\t\t<option label=\"This is the label - no text\" selected=\"selected\">this is text - no value</option> <== LABEL IS DISPLAYED IN LIST\r\n\t</optgroup>\r\n</select>\r\n\r\nPlease consider updating the code.  Let the developer be responsible for providing the correct data in the passed array.  Maybe you could update the instructions to indicate that different browsers handle the options differently.  However, the text attribute is a MUST!\r\n\r\nThanks.\r\n"}}