How to set aria-label to options in select dropdown option?

367 views
Skip to first unread message

trupti Nalawade

unread,
Jun 22, 2015, 10:08:52 PM6/22/15
to knock...@googlegroups.com
I am trying to set aria-label to options text in knockout.

  <select class="form-control dropdown" data-bind="options: vm.testArray,
                       optionsText:'testText'
                       optionsAttr:{'aria-label':'Test'},
                       optionsAttrValue:{'aria-label':'Test'},
                       value: testValue
                       optionsValue: 'testValue',
                       optionsCaption: 'Send to'"></select>

Is there a way to set options attributes?

Michael Best

unread,
Jun 23, 2015, 4:43:01 AM6/23/15
to knock...@googlegroups.com
You can use optionsAfterRender or this custom binding, optionsBind.

 <select class="form-control dropdown" data-bind="options: vm.testArray,
                       optionsText:'testText',
                       value: testValue,
                       optionsValue: 'testValue',
                       optionsCaption: 'Send to',
                       optionsBind: 'attr: {&quot;aria-label&quot;: &quot;Test&quot;}'"></select>

-- Michael
Reply all
Reply to author
Forward
0 new messages