0

대부분의 브라우저에서 작동하지만 IE6,7,8에서 작동하는 jQuery 자동 완성이 있습니다 (IE9에서 작동). 첫 번째 값을 선택한 후 jQuery 자동 완성을 사용하면 아래쪽 화살표를 눌러 가능한 값의 목록을 가져옵니다. 정확히 하나의 항목, 즉 이미 선택된 항목의 목록을 얻습니다. 전체 목록을 원합니다.jQuery UI 자동 완성 및 IE6,7,8의 복수 값

function split(term){ 
    return term.split(/,\s*/); 
} 

control.autocomplete({ 
     minLength: minLength, 
     source: function (request, response) { 
      // delegate back to autocomplete, but extract the last term 
      response($.ui.autocomplete.filter(
       values, split(request.term).pop())); 
     }, 
     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(", "); 
      updateConfiguration(); 
      return false; 
     } 
    }); 

답변

0

IE6,7 및 8은 IE9, Chrome 및 FF와는 다른 분할 기능에서 정규식을 처리합니다. 마지막 요소가 공백으로만 구성되어 있으면 생략됩니다.

function split(val) { 
    //IE deviates from all other browser if the last entry is empty 
    var temp = val.trim(); 
    var endsWithComma = temp.substring(temp.length-1) === ","; 
    temp = endsWithComma ? temp.substring(0,temp.length-1) : temp; 
    var values = temp.split(/,\s*/); 
    if(endsWithComma) 
     values[values.length] = " "; 
    return values; 
} 
고정 이하로 splite의 funciton 변경