0

Stumped on this spacing issue:

Have an auto complete down down menu that shows the symbol and company name of a stock (code below).

I would expect the output to be like this in the drop down

 A      Agilent Technologies 
 AA     American Airlines

But it appears like this:

 A     Agilent Technologies
 AA     American Airlines

A, AA are symbols in this example.

If I used a character instead of a space, say I used '-', it appears fine; properly aligned.

Is there something with how spaces appears in drop down options that is causing this?

.data( "ui-autocomplete" )._renderItem = function( ul, item ) {
   var symbol_len = symbol.length;
   var name_len = name.length;

  if(parseInt(symbol_len) < 15) {
     var diff = 15 - parseInt(symbol_len);

     for(var x=0; x<diff; x++){
       symbol = symbol.concat(' ');
     }   
  }

  symbol = symbol.replace(/ /g, '\u00a0');
R Saudlach
  • 388
  • 1
  • 5
  • 24
  • based on what you have typed, your expected dropdown and actual drop down seems the same. Did you mean to type something different? or is it just me that can't see the difference – Ji_in_coding Jan 27 '15 at 17:55
  • 1
    have you tried ` ` instead of `' '`? – Dave Goten Jan 27 '15 at 17:56
  • I modified the question to show the correct output . thanks @Ji_in_coding – R Saudlach Jan 27 '15 at 18:23
  • Yes I tried   but that does not render as a space in a drop menu option – R Saudlach Jan 27 '15 at 18:25
  • 1
    I don't have a suggestion over the space problem, but can you separate your symbol from your text first, wrap the symbol in a display:block container, and style the container to a uniform width? – Ji_in_coding Jan 27 '15 at 18:57
  • @Ji_in_coding unfortunately option tags cannot contain http://stackoverflow.com/questions/11890597/is-it-posible-to-add-div-or-span-inside-an-option-tag – R Saudlach Jan 27 '15 at 20:15
  • rather than fixing the problem, how about patching it? I know this sounds bad, but give it a shot. Append a   before any A symbol. see if that force alignment? – Ji_in_coding Jan 27 '15 at 21:48

0 Answers0