I need to change behavior for a widget dijit/form/Select
.
Widget should not allow focus (from mouse or using the keyboard) for options which have property disabled: true
.
I would like to know if you can point me out how to achieve this result.
require([
'dijit/form/Select',
'dojo/_base/window',
'dojo/domReady!'
], function(Select, win) {
var select = new Select({
name: 'select2',
options: [{
label: '<i>Swedish Cars</i>',
value: '',
disabled: true
},
{
label: 'Volvo',
value: 'volvo'
},
{
label: 'Saab',
value: 'saab',
selected: true
},
{
label: '<i>German Cars</i>',
value: '',
disabled: true
},
{
label: 'Mercedes',
value: 'mercedes'
},
{
label: 'Audi',
value: 'audi'
}
]
}, 'select');
select.on('change', function(evt) {
console.log('myselect_event');
});
});
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/dojo/1.12.1/dijit/themes/claro/claro.css" />
<script>
window.dojoConfig = {
parseOnLoad: false,
async: true
};
</script>
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.12.1/dojo/dojo.js"></script>
<body class="claro">
<div id="select"></div>
</body>
I was able to solve this issue using a monkey patch.
The solution consist into:
onChange
.I still very interesting to know if another better/cleaner solutions exists.