jQuery UI 자동 완성 기능을 사용 중이고 여러 결과를 제한하려고합니다. 기본적으로 필자는 PM 시스템을 구축 중이며 to 필드에 자동 완성 기능을 사용하고 있습니다. 하지만 한 메시지를 보낼 수있는 사람의 수를 제한하려고합니다. 그래서 최대 선택 수를 25로 제한하십시오.jqueryui 자동 완성 제한 다중 선택
제한 방법이 있습니까? 또한 그들이 최대에 도달 한 시각적 표시기에 대한 아이디어가 있습니까?
select: function(event, ui){
var terms = split(this.value);
if(terms.length <= 2)
{
// 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(", ");
return false;
}
else
{
$(this).effect("highlight", {}, 1000);
$(this).addClass("red");
$("#warnings").html("<span style='color:red;'>Max people reached</span>");
return false;
}
}
http://net.tutsplus.com/tutorials/javascript-ajax/how-to-use-the-jquery-ui-autocomplete-widget/. 어쨌든 상자에 최신 추가 기능을 제거 할 수 있습니까? 다른 이름을 유지하려는 것처럼 사용자가 추가 한 가장 최근의 이름을 제거하려고합니다. http://theproductguy.com/noblecount/noblecount.demo.html 허용되는 최대 문자 수에 도달하면 이러한 종류의 작업이 수행됩니다. – jefffan24
코드에서와 같이'split (term) .pop()'을 사용할 수 없습니까? 추신 : 어쩌면 당신은 이미 당신의 기능을 가지고 있기 때문에 또한 꽤 (페이스 북처럼) => https://github.com/loopj/jQuery-Tokenizing-Autocomplete-Plugin – Alfred
내 스 니펫을 업데이트했습니다. 네가 원하는 것 같아. – Alfred