Skip to content

Commit

Permalink
workaround selectedOptions on IE
Browse files Browse the repository at this point in the history
closes #771
  • Loading branch information
gordonwoodhull committed Aug 18, 2015
1 parent f8627e9 commit aa3e299
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 19 deletions.
21 changes: 17 additions & 4 deletions dc.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dc.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dc.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dc.min.js.map

Large diffs are not rendered by default.

21 changes: 17 additions & 4 deletions src/select-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,23 @@ dc.selectMenu = function (parent, chartGroup) {
}

function onChange (d , i) {
var selectedOptions = Array.prototype.slice.call(d3.event.target.selectedOptions);
var values = selectedOptions.map(function (d) {
return d.value;
});
var values;
var target = d3.event.target;
if(target.selectedOptions) {
var selectedOptions = Array.prototype.slice.call(target.selectedOptions);
values = selectedOptions.map(function (d) {
return d.value;
});
} else { // IE and other browsers do not support selectedOptions
// adapted from this polyfill: https://gist.github.com/brettz9/4212217
var options = [].slice.call(d3.event.target.options);
values = options.filter(function (option) {
return option.selected;
}).map(function(option) {
return option.value;
});
}
// console.log(values);
// check if only prompt option is selected
if (values.length === 1 && values[0] === '') {
values = null;
Expand Down
3 changes: 2 additions & 1 deletion web/examples/select.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</head>
<body>

<p>A meaningless example of multiple selectMenus on some random data...</p>
<div id="select1">
<div>
<a class='reset'
Expand Down Expand Up @@ -101,7 +102,7 @@
datatable
.dimension(letterDimension2)
.group(function(d) { return d.letter; })
.columns(['letter', 'color', 'state'])
.columns(['color', 'state'])
.size(data.length);

dc.renderAll();
Expand Down
21 changes: 17 additions & 4 deletions web/js/dc.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/js/dc.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/js/dc.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/js/dc.min.js.map

Large diffs are not rendered by default.

0 comments on commit aa3e299

Please sign in to comment.