2014-09-04 3 views

답변

1

네, 그냥이 기능 onclick을 호출하고 매개 변수 당신이 선택한 플러그인에 새로운`option` 요소를 만들 것을 의미하는 경우

 function customTags(tagName) 
      { 
       var customTagLength = $('li.search-choice').length; //Custom Option length -1 as compare to actual Option length 
       if(customTagLength>9) 
       { 
        return false; 
       } 
      // above code to limit select value in chosen 


      var html = '<option value="'+tagName+'">'+tagName+'</option>'; 
      $('.chosen-select').append(html); 

    //This is what you need   
      var SearchChoiceArrayTagName = [tagName]; 
      $('.chosen-select').find('option').filter(function (idx, option) { 
      if($.inArray(option.value, SearchChoiceArrayTagName) !== -1) { 
       return option; 
      } 
      }).prop('selected', 'true'); 

      $('.chosen-select').trigger("chosen:updated"); 


        $('.chosen-select').chosen().change(function(e, params){ 
           if(params.deselected==tagName) 
          { 
           $(".chosen-select option[value='"+tagName+"']").remove(); 
           $(".chosen-select").trigger('chosen:updated'); 

          } 
        }); 
      } 
관련 문제