1 onHidePanel: function () { 2 var valueField = $(this).combobox("options").valueField; 3 var val = $(this).combobox("getValue"); 4 var allData = $(this).combobox("getData"); 5 var result = true; 6 for (var i = 0; i < allData.length; i++) { 7 if (val == allData[i][valueField]) { 8 result = false; 9 } 10 } 11 if (result) { 12 $(this).combobox("clear"); 13 } 14 15 }
本文介绍了一个用于验证combobox组件中选择项有效性的JavaScript函数。该函数在combobox面板隐藏时检查所选值是否存在于预设的数据集中,若不存在则清除当前选择。

457

被折叠的 条评论
为什么被折叠?



