jQuery无法在Firefox中点击自动完成下拉框

3

这是我从jQuery官网上找到的一个示例代码:

$(function() {
            var availableTags = [
                "val1",
                "val2",
                "val3",
                "val4",
                "val5"];
            function split( val ) {
                return val.split( /,\s*/ );
            }
            function extractLast( term ) {
                return split( term ).pop();
            }

            $('#tag')
                // don't navigate away from the field on tab when selecting an item
                .bind( "keydown", function( event ) {
                    if ( event.keyCode === $.ui.keyCode.TAB &&
                        $( this ).data( "autocomplete" ).menu.active ) {
                        event.preventDefault();
                    }
                }).autocomplete({
                    minLength: 0,
                    source: function( request, response ) {
                        // delegate back to autocomplete, but extract the last term
                        response( $.ui.autocomplete.filter(
                            availableTags, extractLast( request.term ) ) );
                    },
                    focus: function() {
                        // prevent value inserted on focus
                        return false;
                    },
                    select: function( event, ui ) {
                        var terms = split( this.value );
                        // remove the current input
                        terms.pop();
                        // add the selected item
                        terms.push( ui.item.value );
                        // add placeholder to get the comma-and-space at the end
                        terms.push( "" );
                        this.value = terms.join( ", " );
                        return false;
                    }
                });
        });

<input type="text" name="tag" id="tag" autocomplete="on"/>

这段代码在下拉区域添加了jquery验证之后就无法使用鼠标选择选项了。有什么办法可以解决吗? 我正在使用knockout js。
1个回答

0
解决方案是我使用了错误的jQuery库。

你使用了哪些jQuery库? - antony.ouseph.k
我认为我使用的jQuery UI版本与我的jQuery版本不兼容。那是一段时间之前的事情,所以我不确定,但据我所知,它可以与最新的jQuery库一起使用。 - segFault

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接