EasyUI Forum
May 09, 2024, 10:52:45 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: hiding/showing a combobox  (Read 18432 times)
tomhj
Newbie
*
Posts: 40


View Profile
« on: June 06, 2013, 08:24:35 AM »

Based on a selection in another control, I need to be able to hide/show a combobox field.  I tried using $.hide() and $.show() - but that doesn't seem to work with the combobox.  $.show() results in an extra <select> element while $.hide() still leaves the combobox showing.  It seems combobox works with a shadowy select element that is hidden while the combobox is shown so my calling $.show() reveals that hidden select.

I don't want to use destroy() if I can avoid it because I think that completely removes the HTML component making it harder to show it later.

Any suggestions?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: June 06, 2013, 09:07:22 AM »

The simple way to show/hide the combobox is to wrap it with a <div> and then show/hide this <div>.
Code:
<div id="cc">
  <input class="easyui-combobox"...>
</div>

<script>
$('#cc').show();
//or
$('#cc').hide();
</script>
Logged
tomhj
Newbie
*
Posts: 40


View Profile
« Reply #2 on: June 06, 2013, 09:52:40 AM »

That is what I tried:

Code:
var cb = $('#cb');
if (displayCB) {
    cb.combobox('loadData', []);
    cb.combobox('clear');
    cb.hide();
} else {
    cb.combobox('loadData', newData);
    cb.show()
}

The cb.show() results in a "regular" select appearing to the left of the combobox.
The cb.hide() results in the combobox remaining.

One difference is instead of starting from a <input>, I'm starting with a <select>.  The ComboBox usage examples show that as a valid way to do it.

Update:  I just changed it to an <input> and I'm seeing the same thing - instead of a "regular" select to the left, I'm seeing a "regular" text input control.
« Last Edit: June 06, 2013, 09:56:51 AM by tomhj » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!