2010-04-14 55 views
0
正常工作

我有些脚本,在Firefox和Chrome,但在IE 8的工作我得到这个错误: jQuery的autocompleter不是在IE8

 
$.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 
}; 
` 特定错误曰:“0”为空或不是对象

我可能会改变行[0]为某些东西?这在jquery.autocomplete.js中可以找到,它在firefox中读取的内容相同,并且不会导致错误,所以如果可能的话我并不想真正改变它。

任何意见将有助于感谢!

回答

1

这是我在做什么(基本上我用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