1
votes

TLDR: How do I make the value() respond correctly under the conditions in the jsbin link? http://jsbin.com/pikoye/edit

I am using Kendo UI's ComboBox and have hit upon an edge case that I'm hoping someone can help me with. I am using a combo box as a means to show a MRU list of commands. With the steps stated below, if the user selects a command but then either changes their mind or edits it, the resulting value() still has the value from the selected item.

  1. Select an item on the list with your mouse
  2. The cursor is now at the end of the text in the textbox
  3. Select all the text
  4. Type 'something' and press enter
  5. Alert will show Value of selected item but Text of 'something'.

I've tried the other keypress events to try to change the timing but haven't had any luck with that. It happens in IE11, Chrome, and Firefox. I've also tried different version of KendoUI. We want to be able to have the user press enter to submit their choice, so that has to stay. My solution is to use the text() value, which works for now, but it seems like value() should work.

Update: What I would like is for the Value() to return 'something' instead of the index of what ever you previously selected. I can compare Text() to the index's text value but it seems like it is an unnecessary comparison. To see the values I expected to see, click the 'Customize' button.

1

1 Answers

0
votes

I have provided a possible solution in this jsbin for you http://jsbin.com/vupagekizu/1/

Hopefully I have understood what it is you are after.

Basically all I have done is added a Select event onto the combobox for you that checks to see if the index of the selected item is greater than -1 i.e. an item in the list and if it is then the system stores it in a global variable for you to access. In order to get all the properties of the item I have selected the dataItem associated with the selected item.

var selectedValue = null;


 select: function(e)
    {
      if(e.item.index() > -1)
        {
          selectedValue = this.dataItem(e.item.index());
      alert(selectedValue);
        }
      else 
        {
          //do nothing.
        }          
    }