esayUI.combobox()精准匹配后无法触发.onselect

esayUI的.combobox()精准匹配后无法触发.onSelect:function(data){}
ID为prodSel下拉框模糊查询匹配数据,如果模糊查询内容是输入的全部内容时点击选中的行无法触发onSelect:,只有是输入部分内容通过模糊查询选中行才会触发onSelect


```javascript
代码如下:
  $("#prodSel").combobox({
        url:dataCustId?(rootPath+'/product/productList?custId='+dataCustId):(rootPath+'/product/productList?custId='+opCustId),
        method:'get',
        valueField:'scProductId',
        textField:'prodName',
        editable:true,
        panelHeight:'200',
        onLoadSuccess:function(){
            if(dataProductId&&firstLoadFlag2){
                firstLoadFlag2 = false;
                $('#prodSel').combobox('setValue',dataProductId);
            }
        },
        filter: function(q, row){
            firstLoadFlag2 = false;
        //    $('#prodSel').combobox('setValue',dataProductId);
            var texts = row.prodName;
            var opts = $(this).combobox('options');
            if(texts.toLowerCase().indexOf(q.toLowerCase())> -1){
                return row[opts.textField];
            }
        },
        onSelect:function(data){
            $("#moduleSel").combotree('setValue','');
            $("#moduleSel").combotree('reload',rootPath+'/product/moduleTree?productId='+data.scProductId);
            // $("#projectList").append(str);
        }
    });


```

【以下回答由 GPT 生成】

这个问题是因为在filter函数中,当匹配的内容是输入的全部内容时,没有返回row[opts.textField],导致无法触发onSelect函数。以下是修复该问题的解决方案:

  $("#prodSel").combobox({
        url:dataCustId?(rootPath+'/product/productList?custId='+dataCustId):(rootPath+'/product/productList?custId='+opCustId),
        method:'get',
        valueField:'scProductId',
        textField:'prodName',
        editable:true,
        panelHeight:'200',
        onLoadSuccess:function(){
            if(dataProductId&&firstLoadFlag2){
                firstLoadFlag2 = false;
                $('#prodSel').combobox('setValue',dataProductId);
            }
        },
        filter: function(q, row){
            firstLoadFlag2 = false;
        //    $('#prodSel').combobox('setValue',dataProductId);
            var texts = row.prodName;
            var opts = $(this).combobox('options');
            if(texts.toLowerCase().indexOf(q.toLowerCase()) > -1){
                return row[opts.textField];
            } else if (row[opts.textField].toLowerCase() === q.toLowerCase()){
                return row[opts.textField];
            }
        },
        onSelect:function(data){
            $('#moduleSel').combotree('setValue','');
            $('#moduleSel').combotree('reload',rootPath+'/product/moduleTree?productId='+data.scProductId);
            // $('#projectList').append(str);
        }
    });

修复后,如果匹配的内容是输入的全部内容,点击选中的行也能够触发onSelect函数了。


如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^