Welcome Guest, Not a member yet? Register   Sign In
jQuery UI Autocomplete with CI ??
#17

[eluser]pickupman[/eluser]
I've already [url="http://ellislab.com/forums/viewreply/745033/"]posted[/url] the complete jquery.autocomplete part above, and the only thing you need to supply is a json response with label, item, & value for each row in DB from your controller.

Here's an example I am using
Code:
//In Location.php controller
public function json_zip(){
        
        $search = $this->input->post('term');
        
        if(!IS_AJAX || empty($search))
            redirect('location');
        
        $data['response'] = 'false';
        
        $locations = $this->location_m->get_city_zip_search( $search );
        
        if(count($locations) > 0){
            $data['message'] = array();
            
            foreach($locations as $location){
               $data['message'][] = array(  'label' => $location->city . ', ' . $location->state . ' ' . $location->zip,
                                            'item'  => $location->zip,
                                            'value' => $location->zip );
            }
            
            $data['response'] = 'true';
        }
        echo json_encode($data);      
     }

//jQuery in head tag of view
$("input[name='zip']").autocomplete({
        source: function(req, add){
                $.ajax({
                    url: '<?php echo site_url('location/json_zip');?>',
                    dataType: 'json',
                    type: 'POST',
                    data: req,
                    success: function(data){
                        if(data.response =='true'){
                           add(data.message);
                        }
                    }
                });
        },
        minLength: 3,
        select: function(event, ui){
            $(this).end().val(ui.item.value);
        }
     });


Messages In This Thread
jQuery UI Autocomplete with CI ?? - by El Forum - 04-30-2010, 07:22 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 05-01-2010, 03:27 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 05-01-2010, 04:21 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 05-01-2010, 04:25 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 05-01-2010, 05:15 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 05-01-2010, 05:34 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 05-01-2010, 05:41 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 05-01-2010, 10:13 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 05-01-2010, 10:20 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 05-01-2010, 11:36 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 05-01-2010, 08:46 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 05-02-2010, 09:19 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 05-02-2010, 09:41 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 05-02-2010, 09:02 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 05-02-2010, 09:08 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 06-08-2010, 12:39 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 06-08-2010, 01:01 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 06-08-2010, 06:29 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 06-08-2010, 06:56 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 06-09-2010, 09:18 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 06-09-2010, 10:01 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 06-09-2010, 10:53 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 07-02-2010, 01:45 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 07-02-2010, 02:15 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 07-02-2010, 03:23 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 07-02-2010, 03:25 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 07-02-2010, 03:33 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 07-02-2010, 09:08 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 09-08-2010, 11:40 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 09-09-2010, 06:39 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 09-09-2010, 06:50 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 09-09-2010, 11:25 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 09-10-2010, 06:52 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 10-03-2010, 11:43 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 10-03-2010, 12:20 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 10-03-2010, 03:07 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 10-03-2010, 03:14 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 10-08-2010, 12:20 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 10-08-2010, 02:02 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 10-08-2010, 02:27 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 10-08-2010, 03:29 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 10-08-2010, 06:53 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 10-20-2010, 01:22 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 10-20-2010, 01:53 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 10-20-2010, 02:01 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 07-15-2011, 10:46 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 07-15-2011, 10:59 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 07-15-2011, 11:57 AM
jQuery UI Autocomplete with CI ?? - by El Forum - 07-27-2011, 12:59 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 07-27-2011, 01:25 PM
jQuery UI Autocomplete with CI ?? - by El Forum - 07-27-2011, 02:40 PM



Theme © iAndrew 2016 - Forum software by © MyBB