aid

Friday, 3 April 2015

Typeahead in codeigniter

typeahead in codeigniter

First you must load the base jquery  files and one also for typeahead that is typeahead.js
typeahead.js provides all the function related to auto search and auto complete in in javascript  file.
after that you can use below code for using typeahead.


This is the combination of php and javascript what i have used. $data->L_C_Name; passed from controller in my current view.

"#category"" is the name of text box in which i want to typeahead and autosearch.

<script type="text/javascript">
                  $('#category').typeahead({
                     source: [<?php foreach ($lib_cats as $data) {
               
                     ?>'<?php echo $data->L_C_Name; ?>',
                  <?php } ?>]
                 });
</script>

No comments:

Post a Comment