Autocomplete in a table cell

Asked

Viewed 212 times

0

I’m having trouble adjusting this example of autocomplete to my table. I intend to put the autocomplete in the designation cell. What happens is the following:

HTML TABLE

<table class="table table-striped table-bordered" id="vendaTabela" width="100%" >
 <thead>
   <tr>
     <th data-class="expand">Cód.</th>
     <th data-hide="phone">Designação</th>
     <th data-hide="phone">Qnt.</th>
     <th data-hide="phone,tablet">Uni.</th>
     <th>Preço</th>
     <th>Desconto</th>
     <th>IVA</th>
     <th>Sub-Total</th>
     <th></th>
   </tr>
 </thead>
 <tbody>
   <tr id="tr0">
     <td class="codigo" contenteditable="true" onblur="codArtigo ( )"></td>
     <td id="tags" class="designacao" contenteditable="true" onblur="nomeArtigo()"></td>
     <td class="quantidade" contenteditable="true" onblur="subtotal ( )"></td>
     <td class="unidade" contenteditable="false"></td>
     <td class="preco" contenteditable="true"></td>
     <td class="desconto" contenteditable="true"></td>
     <td class="iva" contenteditable="false"></td>
     <td class="total" contenteditable="false"></td>
    </tr>
  </tbody>
</table>

JAVASCRIPT

var availableTags = [
            "ActionScript",
            "AppleScript",
            "Asp",
            "BASIC"

        ];
$( "#tags" ).autocomplete({
   source: availableTags
        });

So far all well the question is that by putting the 'id="tags"' in the designation 'td', it spoils the layout of the table:

inserir a descrição da imagem aqui

Make me there a kind of designation collapse with quantity. Someone knows what might be?

EDIT

When inspecting element, it is adding one :

inserir a descrição da imagem aqui

Is there any way to "run away" from it ?

  • I tested your code here on Jsfiddle and it looked perfect. http://jsfiddle.net/br9xx888/

  • Strange, then it will have to do with the layout of my table ?! The autocomplete appears to me, but the layout is all crooked :s

  • I realize that there is one less column in your tbody, some column is added dynamically? Because even without one of the columns the layout would behave well. There would only be a blank column. Is there any javascript adding colspan properties for example in your table? Scan through the browser console and see what’s going on... I don’t know what it might be, so I kick possibilities...

  • That was to copy to here, that column actually exists and has a button :) the columns match

  • In the generated html, you inspected if it is not being created with some kind of colspan ? Maybe added by javascript for example?

  • You are creating a span for me. I made an Edit in the question. Do you know how to delete it ? Thanks in advance for the help

  • http://stackoverflow.com/questions/12791984/jquery-ui-autocomplete-adding-a-span Here’s a possible solution

  • where do I put that? . ui-helper-Hidden-accessible { display:None; }

  • I’ve done it, thank you very much ;)

  • Sorry I just saw your comments, but glad you solved your problem.

Show 5 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.