Deleting all the text from an ajax combobox doesn't cause the selectedindex to change. If I select item 0 then delete everything, or leave only spaces, it still says item 0 is selected. Is anyone aware of a solution? Besides "dropdownlist", which I regret more and more trying to replace with this terrible, terrible, pretty, but terrible control...
0
votes
1 Answers
0
votes
$(".formcombobox :input[type=text]").each(function (i) {
this.onblur = function () {
var comboBox = $find(this.parentNode.parentNode.parentNode.parentNode.parentNode.id); // the combobox
if (jQuery.trim(comboBox.get_textBoxControl().value) == "") { // if textbox is empty
comboBox.set_selectedIndex(-1); // then set selected index to -1
}
}
});
Assuming the combobox has class="formcombobox", this attaches an onblur event to the textbox, and the set_selectedIndex() function triggers the change event, so this will correct the index when the user leaves a blank value and allow me to handle the change
I feel like there's probably a better way to get the parent but, whatever. It's good enough for me
I wonder if having a legitimate blank option would've went differently...