Part of the EllisLab Network
   
4 of 5
4
jQuery AJAX autocomplete with CodeIgniter
Posted: 07 June 2009 04:48 PM   [ Ignore ]   [ # 31 ]  
Summer Student
Total Posts:  14
Joined  01-31-2008
rwzhao - 31 May 2009 04:50 AM
naren_nag - 27 May 2009 06:56 AM

Honestly, this has me totally stumped. Would you mind emailing the models, views and controllers to me where you’re trying to implement this.

Autocomplete is working for me on IE7 as well as IE8 so I really can’t figure it out.

cheers,

Nag

Here is what I get from I.E. error message:

Message: Expected identifier, string or number
Line: 548
Char: 2
Code: 0
URI: http://js/jquery.autocomplete.js

Will it help?

It works in I.E. after I put the following at the top of the html view:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
  “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

But the dropdown is long with blank at the top and serached result at the bottom. I am glad at least that I get it working in I.E.

Profile
 
 
Posted: 07 June 2009 11:13 PM   [ Ignore ]   [ # 32 ]  
Grad Student
Avatar
Rank
Total Posts:  83
Joined  01-28-2009
rwzhao - 07 June 2009 08:48 PM

It works in I.E. after I put the following at the top of the html view:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
  “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

But the dropdown is long with blank at the top and serached result at the bottom. I am glad at least that I get it working in I.E.

Wow! That’s a doozy. Does switching the doctype to XHTML 1.1 help? This looks to be a CSS issue.

Great job figuring it out.  surprised

Profile
 
 
Posted: 15 June 2009 02:01 AM   [ Ignore ]   [ # 33 ]  
Lab Assistant
RankRank
Total Posts:  106
Joined  01-30-2008

Thanks for the contribution but I’m getting the following error with your code.

syntax error
active =
http://server/assets/js/autocomplete/jquery.autocomplete.js
Line 557

[removed][removed]
[removed][removed]
[removed][removed]

<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/js/autocomplete/jquery.autocomplete.css" />
[removed]
$(function() {
    
$("#client_name").autocomplete("/edit_customer/search",{
         minChars
:3,
         
matchSubset:1,
         
matchContains:1,
         
cacheLength:10,
         
onItemSelect:selectItemselectOnly:1elementID:'cust_id',
    
});
});

function 
selectItem(lielementID{
    
$("#"+elementID).val(0);
    var 
setVal = (li.extra) ? li.extra[0] 0;
    $(
"#"+elementID).val(setVal);
}
[removed] 

And my controller:

function search($search)
    
{
        $this
->db->like('last_name'$search);
        
$result $this->db->get('customers');
        
        if ( 
$result->num_rows() > ):
            foreach (
$result->result() as $c ):
                echo 
"$c->first_name $c->last_name|$c->id\n";
            endforeach;
        else:
            echo 
'No Results Found|0';
        endif;
    
Profile
 
 
Posted: 15 June 2009 02:22 AM   [ Ignore ]   [ # 34 ]  
Grad Student
Avatar
Rank
Total Posts:  83
Joined  01-28-2009

Hi,

I’m sorry, I haven’t seen this error before. Line 557 in the js file is a return statement.

Could you tell me when you’re getting this error? As soon as you load the view, or when you type something into your input box.

cheers,

Profile
 
 
Posted: 15 June 2009 02:34 AM   [ Ignore ]   [ # 35 ]  
Lab Assistant
RankRank
Total Posts:  106
Joined  01-30-2008

Just committed to my dev server and everything seems to be working fine.  Guess it was a local server issue.  Thanks again, I spent most of my day today trying to hack together another method using the $_get with no avail but this has worked great, just wish I found it earlier.

Profile
 
 
Posted: 15 June 2009 03:17 AM   [ Ignore ]   [ # 36 ]  
Grad Student
Avatar
Rank
Total Posts:  83
Joined  01-28-2009

Great!

I know the feeling.

I found the original jquery.autocomplete and kept trying to get it to work with the get method. And then I dived into the js. The code is so well written (and commented) by Dylan Verheul, that I was able to have it up and running in double quick time smile

cheers

Profile
 
 
Posted: 12 October 2009 02:52 AM   [ Ignore ]   [ # 37 ]  
Summer Student
Total Posts:  1
Joined  10-12-2009

Thanks for the compliments guys! If you get stuck, you can always e-mail me: <firstname>.<lastname> (at) gmail.com.

Dylan Verheul

Profile
 
 
Posted: 19 October 2009 08:43 AM   [ Ignore ]   [ # 38 ]  
Grad Student
Avatar
Rank
Total Posts:  33
Joined  02-19-2009

Nag’s website with the implementation instructions seems to be down. I actually got it all working, but would love to see how some of you have integrated it with CSS for some slick dropdown lists, etc. Any examples?

Profile
 
 
Posted: 11 November 2009 06:52 PM   [ Ignore ]   [ # 39 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  241
Joined  04-11-2008

I second @k00k

 Signature 

Joomla! and custom web apps

Profile
 
 
Posted: 12 November 2009 02:08 PM   [ Ignore ]   [ # 40 ]  
Summer Student
Total Posts:  1
Joined  11-12-2009

Seems that i can’t get it work .. i tried it many times!:(

Profile
 
 
   
4 of 5
4