代码之家  ›  专栏  ›  技术社区  ›  Peter Di Cecco

jQuery UI autocomplete在IE中不起作用

  •  4
  • Peter Di Cecco  · 技术社区  · 16 年前

    我在jQueryUI1.8rc3中使用了新的autocomplete小部件,在Firefox中运行得非常好。在IE里一点用都没有。有人能帮我吗?

    HTML格式:

    <input type="text" id="ctrSearch" size="30">
    <input type="hidden" id="ctrId">
    

    Javascript代码:

    $("#ctrSearch").autocomplete({
        source: "ctrSearch.do",
        minLength: 3,
        focus: function(event, ui){
            $('#ctrSearch').val(ui.item.ctrLastName + ", " + ui.item.ctrFirstName);
            return false;
        },
        select: function(event, ui){
            $('#ctrId').val(ui.item.ctrId);
            return false;
        }
    });
    

    红色的盒子是 <ul> 由jQuery创建的元素。

    Line: 116
    Error: Invalid argument.

    当我在IE8脚本调试器中打开它时,它会高亮显示 f[b]=d https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js ).

    我试过去掉一些选项,但即使我打电话 .autocomplete()

    再说一次,它在Firefox中有效,但在IE中无效。有什么建议吗?

    谢谢。

    更新: this other Stack Overflow question 那是几天前贴的。

    this.element.height ,当它应该使用函数时 this.element.height()

    2 回复  |  直到 7 年前
        1
  •  5
  •   jitter    16 年前

    如果我没弄错的话,你提到的那行好像是第4618行 jquery.1.4.2.js style 功能。这只能意味着Autocompleter插件试图设置IE8不理解或不允许以这种方式访问/更改的样式值。

    style[ name ] = value; //style == elem.style from the passed in element
    
        2
  •  1
  •   jedmao    15 年前

    $(this).css('background', 'rgba(64,255,64,.4)');
    

    jQuery试图做的。。。

    style [ 'background' ] = 'rgba(64,255,64,.4)';
    

    当然,它失败了,因为rgba不是internetexplorer支持的CSS值。所以这次不是你一个人干的,但就我而言,我只是做错了。适当的jQuery语法如下。。。

    $(this).css({backgroundColor: '#40ff40', opacity: .4});
    

    这是我的消息来源。。。

    http://www.cjs.me.uk/blog/?p=238