Autocomplete from Database

Discuss anything that's related to the Raxan framework

Autocomplete from Database

Postby anfuet » Thu Apr 26, 2012 2:10 pm

How I can include an autocomplete function in which datas are from my db?

I tried this:
Code: Select all
$(function() {
                $("#tags").autocomplete({
                source: "index.php",
                minLength: 2});;
             });


But it does not work :(
anfuet
 
Posts: 6
Joined: Tue Apr 24, 2012 1:40 pm

Re: Autocomplete from Database

Postby raymond » Fri Apr 27, 2012 4:23 am

Hi,

You can use the dump() method on the Page controller to return the list of values to the widget:

$this->dump(json_encode(array('item1','item2', 'item3')));

__
Raymond
raymond
Site Admin
 
Posts: 215
Joined: Tue Mar 17, 2009 5:04 am

Re: Autocomplete from Database

Postby anfuet » Wed May 02, 2012 10:50 am

raymond wrote:$this->dump(json_encode(array('item1','item2', 'item3')));


I tried it, but it doesn't work.
anfuet
 
Posts: 6
Joined: Tue Apr 24, 2012 1:40 pm

Re: Autocomplete from Database

Postby raymond » Wed May 09, 2012 12:43 am

Try accessing the page directly to see it it outputs the following values:

Code: Select all
 ["item1", "item2", "item3"]


There shouldn't be any html tags in the output. View the page source to make sure.
__
Raymond
raymond
Site Admin
 
Posts: 215
Joined: Tue Mar 17, 2009 5:04 am


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 1 guest

cron