CodeIgniter Forums

Full Version: jQuery UI Autocomplete with CI ??
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6

El Forum

[eluser]seanloving[/eluser]
Does anybody know how to setup the jQuery UI Autocomplete for use with Codeigniter?

I see that the jQuery plugin on the wiki has a solution for the older jquery.autocomplete.js, but I wonder what is the trick to integrate jquery.ui.autocomplete.js with CI ??

Yes I got jQuery UI working with local data, as in this example

But how do I make jQuery UI work with remote data, like in this other example?


Thanks
Sean Loving

El Forum

[eluser]Mareshal[/eluser]
Same as first example.

If you look inside the source of the 2nd example you find this code:

Code:
$("#birds").autocomplete({
            // TODO doesn't work when loaded from /demos/#autocomplete|remote
            source: "search.php",
            minLength: 2,
            select: function(event, ui) {
                log(ui.item ? ("Selected: " + ui.item.value + " aka " + ui.item.id) : "Nothing selected, input was " + this.value);
            }
        });

Source file is search.php, so the autocomplete sends a request to search.php and it returns some data with echo.

You could call this directly like: search.php?q=test

El Forum

[eluser]technovicebd[/eluser]
I have also applied jquery autocomplete in my one of my project, check it out:
http://sirki3.com/compareprice ..try to write something in search box. If that's gonna work for you, then I can speak up.


thanks

El Forum

[eluser]Mareshal[/eluser]
What should I get? is a complete mess in your code.

El Forum

[eluser]technovicebd[/eluser]
Excuse me Mr Mareshal, I think you are not the owner of the post. How do you know my code is a complete mess??Are u insane? Think twice before replying any post. It will be good for everyone not to waste time.

El Forum

[eluser]seanloving[/eluser]
[quote author="Mareshal" date="1272724064"]
Source file is search.php, so the autocomplete sends a request to search.php and it returns some data with echo.

You could call this directly like: search.php?q=test[/quote]

@Mareshal- do you mean change the javascript from
Code:
..
source: search.php,
..
to something else?

El Forum

[eluser]seanloving[/eluser]
[quote author="technovicebd" date="1272727281"]I have also applied jquery autocomplete in my one of my project, check it out:
http://sirki3.com/compareprice ..try to write something in search box. If that's gonna work for you, then I can speak up.


thanks[/quote]

@technovicebd-
Although what you have gives the type of functionality I'm looking for by using jquery.autocomplete.js, my question was about how to use the newer jquery.ui.autocomplete.js

Thanks
Sean Loving

El Forum

[eluser]Mareshal[/eluser]
[quote author="technovicebd" date="1272730559"]Excuse me Mr Mareshal, I think you are not the owner of the post. How do you know my code is a complete mess??Are u insane? Think twice before replying any post. It will be good for everyone not to waste time.[/quote]

1. Your code doesn't have proper indentation
2. Your code uses too many style="" instead of classes or IDs.
3. You include javascript in the entire code
4. your admin panel is a complete mess.

Before replying to me, think twice.

@seanloving: yes, change search.php to your search path,

El Forum

[eluser]technovicebd[/eluser]
@Mr Mareshal: R u bill gates here to judge my coding?? stupidity should have a limit. oil your own machine Mr New Bill Gates.

El Forum

[eluser]seanloving[/eluser]
[quote author="Mareshal" date="1272748413"]
@seanloving: yes, change search.php to your search path,[/quote]

when I use source: availableTags everything works fine. But when I use source: "http://localhost/sample.com/search" it does not work.

Code:
<s-cript type="text/javascript" src="&lt;?php echo base_url()."assets/js/jquery-1.4.2.min.js" ?&gt;">[removed]
    <s-cript type="text/javascript" src="&lt;?php echo base_url()."assets/js/jquery.ui.core.js" ?&gt;">[removed]
    <s-cript type="text/javascript" src="&lt;?php echo base_url()."assets/js/jquery.ui.widget.js" ?&gt;">[removed]
    <s-cript type="text/javascript" src="&lt;?php echo base_url()."assets/js/jquery.ui.position.js" ?&gt;">[removed]
    <s-cript type="text/javascript" src="&lt;?php echo base_url()."assets/js/jquery.ui.datepicker.js" ?&gt;">[removed]
    <s-cript type="text/javascript" src="&lt;?php echo base_url()."assets/js/jquery.ui.autocomplete.js" ?&gt;">[removed]
    var availableTags = ["PT-042-GP", "PT-042-TP", "PT-042-JP", "PT-042-RP", "PT-042-WP", "PT-042L-GP", "PT-042L-TP"];
    $(".product_picker").autocomplete({
        //source: availableTags,
        source: "http://localhost/sample.com/search",
        minLength: 1,
        select: function(event, ui) {
            log(ui.item ? ("Selected: " + ui.item.value + " aka " + ui.item.id) : "Nothing selected, input was " + this.value);
        }
    });

The file search.php is located in my application/controllers/ and I am thinking this is in fact correct.

Not sure if I need the jQuery AJAX helper and hook for CI in order to make this work with "remote data".

My ultimate goal is to autocomplete from MySQL database.
Pages: 1 2 3 4 5 6