Search code examples
comboboxrequiredjquery-easyui

EasyUI change option 'required' dynamically


in html:

 <input id="iCheck" 
    class="easyui-switchbutton"
    data-options="onChange:iCheckChange"
 >
 <input id="iCombo"
    class="easyui-combobox"
    data-options="mode:'remote'
                , disabled: true
                , required: false
                , loader: ...
                "
  >

in script

function iCheckChange(aChecked){
  $('#iCombo').combobox(aChecked?'enable':'disable').combobox('options').required = aChecked;
};

Code: https://jsfiddle.net/0dbog4of/4/

How repaint iCombo as iCombo2 ? change 'required' option don`t redraw component :(


Solution

  • <script>  
      function iCheckChange(aChecked){
       $('#iCombo').combobox(aChecked?'enable':'disable');
       $('#iCombo').combobox('options').required = aChecked;
       $('#iCombo').combobox('textbox').validatebox('options').required = aChecked;
       $('#iCombo').combobox('validate');
    };
    </script>
    

    http://www.jeasyui.com/forum/index.php?topic=6593.0