2012-05-07 5 views
0

태그를 제거하는 기능인 stackoverflow 웹 사이트와 마찬가지로 태그 기능을 구현하고 싶습니다.제거 버튼과 함께 autosuggest 기능을 어떻게 구현합니까?

저는 jquery UI 자동 완성 플러그인을 언급하고 있습니다.

제거 기능이 들어 난 다음 웹 사이트를 참조하고 있습니다 : website link

내가 태그를 쉼표로 구분해야되는 것을 필요로하는 기능을 사용자가 선택할 수있는 태그의 없음에 제한이 있어야한다 &이 있어야한다 태그를 제거하는 기능.

나는 선택 기능에 조항이 있다는 것을 알고 있습니다. 제안.

언급 된 웹 사이트에 제공된 기능을 병합하려고했습니다.

나는 이것을 위해 select 함수를 수정했다.

enter image description here

내가 어떻게이 쉼표 제한 여러 개의 태그입니다 기능 분리를 구현하고 기능을 제거 않습니다

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(""); 
          var friend = ui.item.value, 
       span = $("<span>").text(friend), 
       a = $("<a>").addClass("remove").attr({ 
        href: "javascript:", 
        title: "Remove " + friend 
       }).text("x").appendTo(span); 

       //add friend to friend div 
       span.insertBefore("#txtTopic"); 
          } else { 
           terms.pop(); 
          }        
          this.value = terms.join(","); 
          return false; 
         } 

는 지금은 다음과 같은 결과는 무엇입니까?

답변

관련 문제