删除ajax组合框中的所有文本不会导致selectedindex发生变化。如果我选择0项,然后删除所有内容,或者只留下空格,它仍然显示0项被选中。有没有人知道解决方案?除了"dropdownlist",我越来越后悔试图用这个可怕的,可怕的,漂亮的,但可怕的控件来取代它……
发布于 2012-12-07 04:14:03
$(".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
}
}
});假设combobox具有class="formcombobox",这会将onblur事件附加到textbox,并且set_selectedIndex()函数会触发change事件,因此当用户留下空值时,这将更正索引,并允许我处理更改
我觉得可能有个更好的方法可以找到父母,但是,不管怎样。对我来说已经足够好了
我在想,如果有一个合法的空白选项会不会有不同的结果...
https://stackoverflow.com/questions/13749524
复制相似问题