JQUery 自动完成器在 IE8 中无法正常工作

发布于 2024-08-29 01:59:10 字数 1107 浏览 7 评论 0原文

我有一些脚本可以在 Firefox 和 Chrome 中运行,但在 IE 8 中我收到此错误:

$.Autocompleter.defaults = {
    inputClass: "ac_input",
    resultsClass: "ac_results",
    loadingClass: "ac_loading",
    minChars: 1,
    delay: 400,
    matchCase: false,
    matchSubset: true,
    matchContains: false,
    cacheLength: 10,
    max: 100,
    mustMatch: false,
    extraParams: {},
    selectFirst: true,
//the following line throws the error, read down for error message
    formatItem: function(row) { return row[0]; },
    formatMatch: null,
    autoFill: false,
    width: 0,
    multiple: false,
    multipleSeparator: ", ",
    highlight: function(value, term) {
        return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>])(" + term.replace(/([\^\$()[]{}*.+\?\|\])/gi, "\$1") + ")(?![^<>]>)(?![^&;]+;)", "gi"), "$1");
    },
    scroll: true,
    scrollHeight: 180
};
` the specific error reads: '0' is null or not an object

我可以将 row[0] 更改为其他内容吗?这是在 jquery.autocomplete.js 中找到的,它在 Firefox 中读取相同的内容并且不会导致错误,所以如果可能的话,我真的不想更改它。

任何建议都会有帮助谢谢!

I have some script which is working in firefox and chrome but in IE 8 I get this error:

$.Autocompleter.defaults = {
    inputClass: "ac_input",
    resultsClass: "ac_results",
    loadingClass: "ac_loading",
    minChars: 1,
    delay: 400,
    matchCase: false,
    matchSubset: true,
    matchContains: false,
    cacheLength: 10,
    max: 100,
    mustMatch: false,
    extraParams: {},
    selectFirst: true,
//the following line throws the error, read down for error message
    formatItem: function(row) { return row[0]; },
    formatMatch: null,
    autoFill: false,
    width: 0,
    multiple: false,
    multipleSeparator: ", ",
    highlight: function(value, term) {
        return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>])(" + term.replace(/([\^\$()[]{}*.+\?\|\])/gi, "\$1") + ")(?![^<>]>)(?![^&;]+;)", "gi"), "$1");
    },
    scroll: true,
    scrollHeight: 180
};

`
the specific error reads: '0' is null or not an object

can I perhaps change the the row[0] to something? This is found in jquery.autocomplete.js and it reads the same in firefox and doesn't cause the error, so i don't really want to change this if at all possible.

any advice would help thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

离不开的别离 2024-09-05 01:59:10

这就是我正在做的事情(基本上我使用了 formatItem 函数,但把它拿出来并尝试了你所做的,它有效

function setSearchAutoComplete() {
    $("#txtContactSearch").autocomplete
   ("../DataFiles/MaintainMessages.ashx?what=GU",
       {
           //formatItem: formatItem,
           formatItem:function(row){return "<em>" + row[0] + "<em>";},
           selectFirst: true,
           minChars: 2,
           max: 50,
           cache: false
       }
   );
    $("#txtContactSearch").result(findValueCallback);
}

function findValueCallback(event, data, formatted) {
    $("#divSelectedContacts").append("<span id='C" + data[1] + "' class='selectedContact'>" + data[0] + "</span>");
}

function formatItem(row) {
    return "<em>" + row[0] + "<em>";
}

。HTH

This is what I am doing (basically I used formatItem function but took that out and tried what you did and it works.

function setSearchAutoComplete() {
    $("#txtContactSearch").autocomplete
   ("../DataFiles/MaintainMessages.ashx?what=GU",
       {
           //formatItem: formatItem,
           formatItem:function(row){return "<em>" + row[0] + "<em>";},
           selectFirst: true,
           minChars: 2,
           max: 50,
           cache: false
       }
   );
    $("#txtContactSearch").result(findValueCallback);
}

function findValueCallback(event, data, formatted) {
    $("#divSelectedContacts").append("<span id='C" + data[1] + "' class='selectedContact'>" + data[0] + "</span>");
}

function formatItem(row) {
    return "<em>" + row[0] + "<em>";
}

HTH

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文