(options)
| 44 | } |
| 45 | |
| 46 | setOptions(options) { |
| 47 | if (!this.el_) { |
| 48 | return; |
| 49 | } |
| 50 | |
| 51 | options = (options || []).map(option => |
| 52 | (typeof option == 'string') |
| 53 | ? {id: option, title: String(option)} |
| 54 | : option); |
| 55 | |
| 56 | if (this.params_.buttons) { |
| 57 | this.el_.empty(); |
| 58 | (options || []).forEach(option => { |
| 59 | $('<input>') |
| 60 | .attr({ |
| 61 | type: 'radio', |
| 62 | name: this.getHtmlId(), |
| 63 | id: `${this.getHtmlId()}-${option.id}`, |
| 64 | value: option.id |
| 65 | }) |
| 66 | .on('change', ev => this.setValueInternal_($(ev.currentTarget).val(), false)) |
| 67 | .appendTo(this.el_); |
| 68 | $('<label>') |
| 69 | .attr('for', `${this.getHtmlId()}-${option.id}`) |
| 70 | .attr('tabindex', 0) |
| 71 | .html(option.title) |
| 72 | .appendTo(this.el_); |
| 73 | }); |
| 74 | } else { |
| 75 | this.selectEl_.empty(); |
| 76 | (options || []).forEach(option => |
| 77 | $('<option>') |
| 78 | .attr('value', option.id) |
| 79 | .text(option.title) |
| 80 | .appendTo(this.selectEl_)); |
| 81 | } |
| 82 | |
| 83 | this.setValueInternal_(this.getValue()); |
| 84 | } |
| 85 | |
| 86 | getValue() { |
| 87 | var value = this.value_; |
no test coverage detected