2017-12-08 25 views
0

저는 에이스 자동 완성기를 사용 해왔고 단어의 길이가 에이스 자동 완성 프로그램의 기본 너비보다 훨씬 큰 경우가 있습니다. 나는 자동 완성에 가로 스크롤하지만, 목록의 맨 아래에있는 단어에 가져다 일부 CSS를 추가 한Autocompleter 너비 변경

enter image description here

컷 받고 있습니다. 비슷한 문제에 직면 해 있고 긴 이름을 보여줄 누군가가 있습니까?

+0

일부 코드도 추가 할 수 있습니까? – locateganesh

답변

0

필자는 자동 완성기에서 가장 긴 문자열의 길이를 가져 와서 문제를 해결 한 다음 문자열의 너비를 결정할 수 있도록 같은 글꼴 크기와 글꼴 모음으로 동일한 문자열을 복제하는 범위를 만들었습니다.

   $('body').append("<span id='longText'></span>"); 
       var longElement = $('body').find("#longText"); 

       longElement.text(longestValue); //longestValue containts the Long String 
       var longeElementWidth = longElement.width(); 
       var autoCompleterWidth = $(".ace_autocomplete").width(); 

       if (longeElementWidth > autoCompleterWidth) { 
        var newAutoCompleteWidth = longeElementWidth + 15 + "px"; 

        $(".ace_editor.ace_autocomplete").width(newAutoCompleteWidth); 
       } else { 
        //Defaulting the width of the autocompleter to 350px 
        $(".ace_editor.ace_autocomplete").width("350px"); 
       }       
       longElement.remove();