Deprecated: Creation of dynamic property ext::$ajax_file is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$js_path is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$fallback is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$caching is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$ajax_view is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$debug is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$ip_debug is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$init_url is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$camelize is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$camelizeUcfirst is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$upload_dir is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$preview_url is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$ajax_file is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$js_path is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$fallback is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$caching is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$ajax_view is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$debug is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$ip_debug is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$init_url is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$camelize is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$camelizeUcfirst is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$upload_dir is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$preview_url is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: addslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/core.class.php on line 1575

Deprecated: Creation of dynamic property ext::$file is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$method is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: addslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/core.class.php on line 1575

Deprecated: Creation of dynamic property ext::$file is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$method is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$file is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$method is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$file is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$method is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$file is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$method is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$file is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$method is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$file is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$method is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$file is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$method is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$file is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$method is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: addslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/core.class.php on line 1575

Deprecated: Creation of dynamic property ext::$file is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$method is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: addslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/core.class.php on line 1575

Deprecated: Creation of dynamic property ext::$file is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: Creation of dynamic property ext::$method is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/ext.class.php on line 16

Deprecated: addslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/core.class.php on line 1575

Deprecated: addslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home/project-web/cjax/htdocs/cjax/core/classes/core.class.php on line 1575
Ajax Autocomplete

Cjax Framework


Slick, simple and usable autocomplete. This plugin ready to use when you download Cjax, as it already comes included.
From your Ajax controller return an array. That array, is then converted into autocomplete options.
Caching is enabled. If you have already typed a word and undo then retype, it won't make more ajax calls. It will attain previous data.

Examples

PHP
<?php 

    $ajax
->keyup('#text1'$ajax->autocomplete('ajax.php?autocomplete/update'));

    
?>

Try it

Type Something (like a country name).

Cjax 5.9+

Cjax 5.9 adds alot of power to autocomplete. More stability, more scalability, more caching and overall more complete and more features.

Note: These new features should be considered beta, which means, they could change in the future.

Two more optional parameters. boolean $full_load and string $url2

$full_load

Realizing that every time you type a key, triggers an ajax call to the server, you may want to instead load all data at once, and not request the server as much. True / False, this options lets you load all the data at once. Intead of making an ajax request for each letter you type, you can dump a full array of data once, this data is then cached. When used this way, only one ajax call to the server is made. When you type more, the data obtained is filtered to serve the other keys you type.

Additionally, you can -


Preload: Need to load large amount of data? No problem. You can preload it. This can ensure that the autocomplete acts really fast even with very large amounts of data.
With the new caching capabilities, you can take advantage of these caching capabilities by preloading the data you want to use. When the autocomplete kicks in all the data will be already be in place. You can take advanage of this by making an ajax request to the same url you are using for the autocomplete, and using the cache flag in the call() method. This wil cache data, when the autocomplete triggers the request, it will be served from cache, without making any other ajax request.

Preload Example
PHP
<?php 

    
//assuming the method is ajax.php?autocomplete/full
    //this will cache this data in the client side.
    //If you trigger any more requests to this url they will be served from cache, and the same response that was obtained the first time
    //will be served all the time.
    
$ajax->call(array('autocomplete','full',null, array('cache' => true)));

    
?>
$url2
If you would like to trigger an ajax request when of the one items is selected in the autocomplete, here is where you do it. Specifiy a $url by default, the name of the item you select will be added to the url as a controller parameter. In your ajax contoller you should get this name in the first argument. You can also choose to send an id instead, if your original data array contains ids, you can specify a forth parameter with the word 'id' and the id will be sent.
PHP
<?php 

    $ajax
->keyup('#text2'$ajax->autocomplete('ajax.php?autocomplete/full'true ,'ajax.php?controller/method','id'));

    
?>

Note: Current limitation in autocomplete you can only have one instance on a page.

Previous Topic:  Previous Class    ·   Top of Page   ·   Demos Home   ·  

CodeIgniter  ·  Copyright © 2006 - 2012  ·  Cjax