Search code examples
jqueryyiijquery-tokeninput

In TokenInput, I want the resultformatter to display "No result" when the user typing data is not available?


<div class="row">
     <div class="floatleft" style="width:110px;"><?php echo CHtml::label('TO :','',array('class'=>'label_name',));?></div>
       <div class="floatleft"><?php $this->widget('application.extensions.tokeninput.TokenInput', array(
    'model' => $model,
    'attribute'=>'TO',
    'id'=>'TO',

    'url' => $this->createUrl('User/autocomplete'),
    'options' => $arrOptions
    )
); ?></div>

$arrOptions['allowCreation'] = true;
$arrOptions['preventDuplicates'] = true;
$arrOptions['resultsFormatter'] ='js:function(item){ 

    return "<li><p>" + item.name + "</p></li>" 
    }';
$arrOptions['theme'] = 'facebook';

I have a token input for a list of user names, when one type a name which does not exist I want to display "No result found", I know I have to change resultsFormatter, but I don't know how to check the existing data with the term item?


Solution

  • Well existing data is checked itself by plugin but if you mean that you want to change the text of "No Results Found" use option

    noResultsText: "Alternate No Results found"