jQWidgets Forums
jQuery UI Widgets › Forums › Lists › ComboBox › How to delete a value in ComboBox
Tagged: combobox
This topic contains 10 replies, has 2 voices, and was last updated by damc 11 years, 11 months ago.
-
Author
-
Hi,
I have two problems.
1. placeHolder propertie does not work on IE8 and IE9.
2. How to delete value in combo (set to null). If user use BACKSPACE or DELETE key combo keeps old value?
Thank you for your help.
Hi,
1. placeHolder requires a browser which supports HTML5. Otherwise the INPUT tag’s placeholder attribute is not available. See: http://www.w3schools.com/tags/att_input_placeholder.asp
2. You cannot delete a value from the ComboBox using Keyboard keys. You can just delete the text displayed in its input field.Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Hi Peter,
Item 2.
What about to use event unselect and there set value to null?Thank you for your answer.
Hi Peter,
On unselect event I set value with jQuery’s val: $(“#jqxComboBox”).val(”). This works.
If I have turn on autoComplete then does not work. Combo set’s value on first element. Can you help me?
Thank you!
Hi Peter,
Can you help me.
If is it autoComplete on, I have problem with setting value on empty. How to implement, that user can delete value on combo and is autocomplete on?
Thank you.
Hi damc,
What do you mean by clear the value and setting it to empty? Clear the selection, clear the text in the input field, delete an item or something else?
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Hi Peter,
I would like to clear value in combo when user delete text with BACKSPACE or DELETE key.
My code:
On unselect event I set value with jQuery’s val: $(“#jqxComboBox”).val(”). If I have autoComplete = false then this code sets combo’s value to empty. If I have autoComplete = true then doesn’t work because combo sets value on first element.I debug code and found difference in args object
$(“#jqxComboBox”).on(‘select’, function (event) {
var args = event.args;1. autocomplete = false -> index = -1:
args: Object
index: -1
item: null
owner: a.jqx.define.b.(anonymous function)
type: “none”
__proto__: Object2. autoComplete = true -> index = 0
args: Object
index: 0
item: Object
owner: b.(anonymous function)
type: “none”
__proto__: ObjectThank you for your help.
Hi damc,
From your explanation, I understand that you want to clear the selection, not to delete an item. You can clear the selection by calling:
$("#jqxComboBox").jqxComboBox('clearSelection');
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Hi Peter,
On unselect event I have already try this command $(“#jqxComboBox”).jqxComboBox(‘clearSelection’) and this $(“#jqxComboBox”).jqxComboBox(‘selectIndex’, -1 ) and all three together:
$("#jqxComboBox").jqxComboBox('clearSelection') ;$("#jqxComboBox").jqxComboBox('selectIndex', -1 );$(“#jqxComboBox”).val(”);
It is steel the same problem like I wrote it.
Best regards,
DamcHi,
I do not think that “unselect” is the appropriate place for clearing a selection. As far as I understand, you want this to happen on key down when a key is pressed in the input field. I suppose that then you bind to the ComboBox Input field’s keydown event, check whether the pressed key is “Backspace” or “Del” and call the “clearSelection” method when necessary.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Hi Peter,
I have changed my code:
$("#jqxComboBox").on('keydown', function (event) { if (event.keyCode == 8 || event.keyCode == 46) { $("#jqxComboBox").jqxComboBox('clearSelection'); }});
This also doesn’t work. Combo still selects first item.
Best regards,
Damc -
AuthorPosts
You must be logged in to reply to this topic.