Part of the EllisLab Network
   
4 of 5
4
jQuery AJAX autocomplete with CodeIgniter
Posted: 07 June 2009 03:48 PM   [ Ignore ]   [ # 31 ]  
Summer Student
Total Posts:  8
Joined  01-31-2008
rwzhao - 30 May 2009 11:50 PM
naren_nag - 27 May 2009 01: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 10:13 PM   [ Ignore ]   [ # 32 ]  
Grad Student
Avatar
Rank
Total Posts:  81
Joined  01-28-2009
rwzhao - 07 June 2009 03: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 01:01 AM   [ Ignore ]   [ # 33 ]  
Lab Assistant
RankRank
Total Posts:  102
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:selectItem, selectOnly:1, elementID:'cust_id',
    
});
});

function
selectItem(li, elementID) {
    
$("#"+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() > 0 ):
            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 01:22 AM   [ Ignore ]   [ # 34 ]  
Grad Student
Avatar
Rank
Total Posts:  81
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 01:34 AM   [ Ignore ]   [ # 35 ]  
Lab Assistant
RankRank
Total Posts:  102
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 02:17 AM   [ Ignore ]   [ # 36 ]  
Grad Student
Avatar
Rank
Total Posts:  81
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 01: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 07:43 AM   [ Ignore ]   [ # 38 ]  
Summer Student
Avatar
Total Posts:  18
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 05:52 PM   [ Ignore ]   [ # 39 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  185
Joined  04-11-2008

I second @k00k

 Signature 

Itexa

Profile
 
 
Posted: 12 November 2009 01: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
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120464 Total Logged-in Users: 33
Total Topics: 126542 Total Anonymous Users: 3
Total Replies: 665376 Total Guests: 287
Total Posts: 791918    
Members ( View Memberlist )