Search code examples
jqueryhtmljquery-select2footable

select2 not working inside fooftable


Why select2 is not working inside a footable?

I want to put a select2 in a fooftable cell.

<td>
   <select class="form-control" id="_products">                                           
      <option value="1">Test Product 1</option>
      <option value="2">Test Product 2</option>
      <option value="3">Test Product 3</option>
      <option value="4">Test Product 4</option>
   </select>
</td>

Here is a jsfiddle with the example.

https://jsfiddle.net/aq9Laaew/54155/

I am using jquery-footable 3.1.6 and select2 4.0.6 rc1


Solution

  • You have to call select2 after the footable is rendered.

    $('.footable').footable({},function(){
        $('select.form-control').select2();
    });
    

    https://jsfiddle.net/aq9Laaew/54223/