javascripthtmloracle-jet

Disable a manual keyboard input JavaScript/Oracle JET


I'm developing an application with Oracle JET framework and I'm using a combobox input as shown in the Oracle JET Cookbook.

How can I disable a manual keyboard input?

I tried to add this in my input but none of this command worked:

onkeypress="return false;"
onkeydown="return false"



<input id="combobox" list="browsers" 
       data-bind="ojComponent: {component: 'ojCombobox', 
                                multiple: true, value: val,
                                rootAttributes: {style:'max-width:20em'}}"/>
<datalist id="browsers">
    <option value="Internet Explorer">Internet Explorer</option>
    <option value="Firefox">Firefox</option>
    <option value="Chrome">Chrome</option>
    <option value="Opera">Opera</option>
    <option value="Safari">Safari</option>
</datalist>

Thank you


Solution

  • As Quentin mentioned in comments section combobox purpose is to provide a combination of text input and dropdown menu.

    You can use <oj-select-one> component for your requirement.

    <oj-select-one id="basicSelect" value="{{val}}" style="max-width:20em">
       <oj-option value="IE">Internet Explorer</oj-option>
       <oj-option value="FF">Firefox</oj-option>
       <oj-option value="CH">Chrome</oj-option>
       <oj-option value="OP">Opera</oj-option>
       <oj-option value="SA">Safari</oj-option>
    </oj-select-one>
    

    Here is the link for component demo Oracle Jet SelectOne Menu Demo

    Not sure how it is in jet version you are using but If you wanted to do it with comboxbox only then in jet 5.1 this is working

    <oj-combobox-one id="student" 
        value="{{selectedStudent}}" options="[[studentOptions]]"
        onkeydown="return false;">
    </oj-combobox-one>