2017-12-08 13 views
0

私はエースオートコンプリータを使用していましたが、単語の長さがエースのオートコンプリートのデフォルト幅よりはるかに大きい場合があります。オートコンプリートの幅を変更する

enter image description here

私はオートコンプリートに水平スクロールにもたらすために、いくつかのCSSを追加しましたが、リストの一番下にある単語がカットされています。誰もが同様の問題に直面し、長い名前を示すためにいくつかの修正を加えましたか?

+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(); 
関連する問題