Friends
I have got a problem in autocomplete. The searched records are fetched from database. When any user's name are typed it displays with comma separator (,) but it's associated id are override by the current one. What I need is, these ids to be in comma separate form, i.e. 3,6,1,
I tired using push operation but I failed.
So I would like to know your suggestion.
jQuery I have implemented is:
- <?php $this->widget('CAutoComplete',
- array(
- //name of the html field that will be generated
- 'name'=>'user_name[]',
- //replace controller/action with real ids
- 'url'=>array('Privacy/autoCompleteLookup'), // fetch searched record from database
- 'max'=>10, //specifies the max number of items to display
-
- //specifies the number of chars that must be entered
- //before autocomplete initiates a lookup
- 'minChars'=>1,
- 'delay'=>200, //number of milliseconds before lookup occurs
- 'matchCase'=>false, //match case when performing a lookup?
-
- //any additional html attributes that go inside of
- //the input field can be defined here
- 'htmlOptions'=>array('size'=>'40'),
-
- 'methodChain'=>".result(function(event,item){\$(\"#allow\").val(item[1]); \$(\"#allow\").prepend(item[1]);})",
- 'multiple' => true,
- ));
- ?>
- <?php echo CHtml::hiddenField('allow'); ?> // html equivalent is : <input type ="hidden" name ="allow" >
jQuery is used in
line number 20 and user id is stored in hidden form,
line number 21
Thank you for your help.