EasyUI Forum
May 17, 2024, 12:53:15 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: combobox combo-value looses it's value  (Read 5524 times)
devnull
Sr. Member
****
Posts: 431


View Profile
« on: May 30, 2014, 07:18:49 PM »

I am using the following code to change the combobox into a normal input field when adding a new record.

Code:
$('.fkey').combobox({
  hasDownArrow:false,
  onShowPanel:function(){
    $(this).combobox('hidePanel');
  }
});

The code does remove the dropdown and prevents the panel from showing, however when I save the form the value of the element is null even if a value is entered into the input field.

It appears that <input type="hidden" class="combo-value" name="XX" value=""> is added to the DOM multiple times.

When the first char is entered
  • there is 1 occurrence of the combo-value element, when the second char is entered [xx] the combo-value disappears, on the 3rd char [xxx] the combo-value input is duplicated, and any chars entered after the 3rd char [xxxx], the combo-value element disappears.

I have also noticed, that the onChange() event gets fired twice when entering text using this method, but only gets fired once when the combobox is selected normally.




« Last Edit: May 30, 2014, 08:57:44 PM by devnull » Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: May 31, 2014, 07:00:55 AM »

The entered value of combo box must be exists in the drop-down items. When drop-down panel is empty, the entered value will be removed since there are no values exists in drop-down items.
To make the combobox works like a textbox, the 'keyHandler' property must be overridden to keep its entered value.
Code:
$('#cc').combobox({
       keyHandler: $.extend({},$.fn.combobox.defaults.keyHandler, {
              query:function(q,e){
                     $(this).combo('setValue', q);
                     $(this).combo('hidePanel');
              },
              enter:function(){}
       })
})
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!