This extension is a wrapper to use my own creation of Ajax Powered Autocomplete. Please, refer to my website to get a detailed description of this plugin.
I have created this extension using the latest Yii but can be used from Yii 1.0 and above.
Unzip the file and:
1.
copy jqAutocomplete.php and jqautocomplete folder to your application's protected/extensions folder.
2. copy test.php to your application's protected/views folder
3. copy TestController.php to your application's protected/controllers folder
4. copy test_layout.php to your application's protected/layouts folder
to run the test just do http://yourapplicationurl/index.php?r=test/autocomplete
Look at the view and you will see something like this:
Yii::import('ext.jqAutocomplete'); $json_options = array( 'script'=> $this->createUrl('test/json',array('json'=>'true','limit'=>6)) . '&', 'varName'=>'input', 'shownoresults'=>true, 'maxresults'=>16, 'callback'=>'js:function(obj){ $(\'#json_info\').html(\'you have selected: \'+obj.id + \' \' + obj.value + \' (\' + obj.info + \')\'); }' ); // #test_json is your text field id // (please refer to the example view page for the field wrap) jqAutocomplete::addAutocomplete('#test_json',$json_options);
Total 11 comments
then you must create multiple instances.
use
instead
Thank you for sharing this.. took me a bit to get it working but it works well. Though i'm still looking to figure out why it breaks when there are 2 on a page.
"Permission denied", that is not an issue with the widget but with your security settings.
I followed the instructions but get:
require(C:\xampp\htdocs\protected\controllers\TestController.php) [function.require]: failed to open stream: Permission denied
fix for comment of code.
i noticed that there was 2 times merge, i think that it will be wise to have like this.
[code] protected static function create($selector, $options = array(), $position = CClientScript::POS_END){ self::registerScript(); $options = CJavaScript::encode(CMap::mergeArray(self::defaultOptions(),$options));
Yii::app()->clientScript->registerScript(__CLASS__.$selector, 'jQuery.autoComplete("'.$selector.'",'. $options.');', $position); } public function addAutocomplete($selector, $opts = array()) { self::create($selector, $opts); }[/code]
could you please help me with an example to search for letters no matter their position inside a word and how to search for a name and submit id instead ?
Thank you
The search server PHP script is just an example, you can modify it to suit your needs.
looks like only knows to search sequential ?
Trying to fix it. Thanks for your report.
I have tried with two fields (as belown) with two script url and it still make request to the first url. Please help to fix this.
Leave a comment
Please login to leave your comment.