title: Autocomplete Codeigniter with modal bootstrap not work
body: <p>I don't know why and how to solve my problem. I'm using CodeIgniter, and I want to create <code>autocomplete</code> for my form on modal bootstrap.</p>
  
  <p>first, let me show you my model.</p>
  
  <pre><code>    function getBarangAjax($keyword){
      $this-&gt;db-&gt;order_by('barang_id', 'DESC');
      $this-&gt;db-&gt;like('barang_kode', $keyword);
      return $this-&gt;db-&gt;get('barang')-&gt;result_array();
  }
  </code></pre>
  
  <p>this is my controller.</p>
  
  <pre><code>    public function getKodeBarangAjax(){
      $keyword = $this-&gt;input-&gt;post('keyword');
      $data = $this-&gt;Model_App-&gt;getBarangAjax($keyword);
      echo json_encode($data);
  }
  </code></pre>
  
  <p>this is my view of modal.</p>
  
  <pre><code>&lt;div class="modal fade" id="modalAddTransaction" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"&gt;
  &lt;div class="modal-dialog modal-lg"&gt;
      &lt;div class="modal-content"&gt;
          &lt;div class="modal-header"&gt;
              &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;&lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;&lt;/button&gt;
              &lt;h4 class="modal-title" id="myModalLabel"&gt;Transaksi Baru&lt;/h4&gt;
          &lt;/div&gt;
  
          &lt;form class="form-horizontal" id="formAddTransaksi" method="post" action="&lt;?php echo site_url('cAdminPage/') ?&gt;"&gt;
          &lt;div class="modal-body"&gt;
  
              &lt;div class="form-group"&gt;
                  &lt;label class="col-lg-2 control-label"&gt;Pilih Transaksi&lt;/label&gt;
                  &lt;div class="col-lg-3"&gt;
                      &lt;select class="form-control" name="transaksiType" id="transaksiType" aria-describedby="basic-addon1"&gt;
                          &lt;option value=""&gt;&lt;/option&gt; 
                          &lt;option value="Regular"&gt;Regular&lt;/option&gt; 
                          &lt;option value="Reseller"&gt;Reseller&lt;/option&gt; 
                          &lt;option value="Dropshipper"&gt;Dropshipper&lt;/option&gt;
                      &lt;/select&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div class="form-group"&gt;
                  &lt;label class="col-lg-2 control-label"&gt;Invoice&lt;/label&gt;
                  &lt;div class="col-lg-3"&gt;
                      &lt;input type="text" class="form-control" name="transaksiInvoice" id="transaksiInvoice" aria-describedby="basic-addon1" /&gt;
                  &lt;/div&gt;
              &lt;/div&gt;              
  
              &lt;div class="form-group"&gt;
                  &lt;label class="col-lg-2 control-label"&gt;Tanggal&lt;/label&gt;
                  &lt;div class="col-lg-3"&gt;
                      &lt;input type="text" class="form-control" name="transaksiTanggal" id="transaksiTanggal" aria-describedby="basic-addon1" /&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div class="form-group"&gt;
                  &lt;label class="col-lg-2 control-label"&gt;Pelanggan&lt;/label&gt;
                  &lt;div class="col-lg-3"&gt;
                      &lt;input type="text" class="form-control" name="transaksiPelanggan" id="transaksiPelanggan" aria-describedby="basic-addon1" /&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div class="form-group"&gt;
                  &lt;label class="col-lg-2 control-label"&gt;Kode Barang&lt;/label&gt;
                  &lt;div class="col-lg-3"&gt;
                      &lt;input type="text" class="form-control" autocomplete="off" name="transaksiKodeBarang" id="transaksiKodeBarang" aria-describedby="basic-addon1" /&gt;
                      &lt;ul class="dropdown-menu txtbarang" style="margin-left:15px;margin-right:0px" role="menu" aria-labelledby="dropdownMenu" id="DropdownBarang"&gt;
                      &lt;/ul&gt;   
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div class="form-group"&gt;
                  &lt;label class="col-lg-2 control-label"&gt;Quantity&lt;/label&gt;
                  &lt;div class="col-lg-3"&gt;
                      &lt;input type="text" class="form-control" name="transaksiQty" id="transaksiQty" aria-describedby="basic-addon1" /&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div class="form-group"&gt;
                  &lt;label class="col-lg-2 control-label"&gt;Harga /pcs&lt;/label&gt;
                  &lt;div class="col-lg-3"&gt;
                      &lt;input type="text" class="form-control" name="transaksiHarga" id="transaksiHarga" aria-describedby="basic-addon1" /&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div class="form-group"&gt;
                  &lt;label class="col-lg-2 control-label"&gt;Total Pembayaran&lt;/label&gt;
                  &lt;div class="col-lg-3"&gt;
                      &lt;input type="text" class="form-control" name="transaksiTotalHarga" id="transaksiTotalHarga" aria-describedby="basic-addon1" /&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div class="form-group"&gt;
                  &lt;label class="col-lg-2 control-label"&gt;Created by&lt;/label&gt;
                  &lt;div class="col-lg-3"&gt;
                      &lt;input type="text" class="form-control" value="&lt;?php echo ($this-&gt;session-&gt;userdata('nama')) ?&gt;" name="transaksiCreatedBy" id="transaksiCreatedBy" aria-describedby="basic-addon1" readonly /&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div class="form-group"&gt;
                  &lt;label class="col-lg-2 control-label"&gt;Created at&lt;/label&gt;
                  &lt;div class="col-lg-3"&gt;
                      &lt;input type="text" class="form-control" value="&lt;?php echo date('Y-m-d H:i:s') ?&gt;" name="transaksiCreatedAt" id="transaksiCreatedAt" aria-describedby="basic-addon1" readonly /&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class="modal-footer"&gt;
              &lt;button type="submit" id="simpan" class="btn btn-sm btn-primary"&gt;Save&lt;/button&gt;
              &lt;button type="button" id="reset" class="btn btn-sm btn-primary"&gt;Reset&lt;/button&gt;
              &lt;button type="button" class="btn btn-sm btn-primary" data-dismiss="modal"&gt;Close&lt;/button&gt;
          &lt;/div&gt;
              &lt;/form&gt;     
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>
  and this is my js.</p>
  
  <pre><code>    $(document).ready(function() {
      $(".addTransaksi").click(function(){
      $('#modalAddTransaction').modal('show');
  
      $("#transaksiKodeBarang").keyup(function(){
          $.ajax({
              type: "POST",
              url: '&lt;?php echo site_url('cAdminPage/getKodeBarangAjax'); ?&gt;',
              data: {
                  keyword: $("#transaksiKodeBarang").val()
              },
              dataType: "json";
              success: function (data){
                  if (data.length &gt; 0){
                      $('#DropdownBarang').empty();
                      $('#transaksiKodeBarang').attr("data-toggle", "dropdown");
                      $('#DropdownBarang').dropdown('toggle');
                  }else if (data.length == 0){
                      $('#transaksiKodeBarang').attr("data-toggle", "");
                  }
                  $.each(data, function (key,value){
                      if (data.length &gt;= 0)
                          $('#DropdownBarang').append('&lt;li role="presentation" &gt;&lt;a role="menuitem dropdownnameli" class="dropdownlivalue"&gt;' + value['barang_kode'] + '&lt;/a&gt;&lt;/li&gt;');
                  });
              }
          });
      });
      $('ul.txtbarang').on('click', 'li a', function () {
          $('#transaksiKodeBarang').val($(this).text());
      });
      });
  });
  </code></pre>
  
  <p><br>
  <br>
  the modal is not showing up.The keyword for autocomplete is <strong>transaksiKodeBarang</strong><br>
  please advice, where did i go wrong?<br>
  thanks.</p>