[eluser]Shaser[/eluser]
Hello everyone I'm working with jquery UI and codeginiter but I have a problem when I try to load a view with jquery autocomplete items and this didn't get a data from a data base. Some body can help me? this is the code:
model
Code:
function showProvider(){
$query = $this->db->select('provider_id, provider_name');
$query = $this->db->from('tbl_provider');
$query = $this->db->order_by("provider_name", "desc");
$query = $this->db->get();
return $query->result();
}
controller
Code:
function providerCombox(){
$this->load->model('mod_Provider');
$datos_vista = "[{";
$cont = 0;
$data = $this->mod_Provider->showProvider();
foreach ($data as $row){
if($cont++>0) $datos_vista .=",";
$datos_vista .= "id:\"$row->provider_id\",name:\"$row->provider_name\"";
}
$datos_vista .="}]";
$this->load->view('new_product',$datos_vista);
}
view
Code:
$( "#provider" ).autocomplete({
source: '<?php echo base_url().'CI_Provider/providerCombox';?>',
minLength: 0,
select: function( event, ui ) {
$( "provider").val(ui.item.name);
},
focus: function( event, ui ) {
$( "#provider" ).val( ui.item.name );
return false;
}
});
});
thank you, sorry for my English