2010-04-14 53 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