CodeIgniter Forums
Still Learning - Need Help - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Still Learning - Need Help (/showthread.php?tid=40185)



Still Learning - Need Help - El Forum - 04-01-2011

[eluser]kre8ivdesigns[/eluser]
So I am building a very database centric website and want to know what is the best way to recall data for something like JQuery autocomplete. I have a table that holds college information. As of now I have Phil Sturgeons Cache file for the get_colleges function and calling that as variables in the view. Looking for feedback:
Code:
$colleges = $this->user_profile->get_form_data_tables('college');
        $this->cache->write($colleges, 'college');
               $data['colleges'] = $this->cache->get('college');

in my views
Code:
var availableTags = [<?php foreach($colleges as $key) { echo '{"value":"'.ucwords($key->name).'","id":'.$key->college_id.'},'; }?>];
                
        $("input#college").autocomplete({
            source: availableTags,
            select: function(event,ui){
                $('#college_value').val(ui.item.id)}
        });