Can anyone please provide some examples how to use cautocomplete formatItem and formatResult property?
Thank you!
Can anyone please provide some examples how to use cautocomplete formatItem and formatResult property?
Thank you!
Ok. I’ve solved my problem. But seems like there is a bug in CAutoComplete formatItem or I’m doing something wrong.
In the documentation for formatItem property it says:
The last parameter "search term" returns exactly the same as the first one "the results row".
Here is the code:
<?php
$this->widget('CAutoComplete',
array(
'name'=>'cn',
'url'=>array('search/suggestcharacter'),
'minChars'=>1,
'delay'=>1500,
'matchCase'=>false,
'htmlOptions'=>array('size'=>'28','class'=>'search-field'),
'cssFile'=>false,
'width'=>'310px',
'scroll'=>false,
'formatItem'=>"function(result, i, num, term) { return result + '(' + term + ')'; }",
));
?>
In the code above result is the same as term. So in my sample search for "New" the results look like:
New Jersey (New Jersey)
New York (New York)
etc.
instead of
New Jersey (New)
New York (New)
etc.
Am I doing something wrong or it’s a bug?
P.S. I don’t really need it for my project, just asking out of curiosity.
Hello, people! Two topics and no answers? What’s going on here?