0

jQuery UI starting from version 1.8.4 html-encodes Autocomplete suggestions (according to this issue).

This became a problem for me now. I used to theme the output for the suggestions, but now (if I use version 1.8.4 or higher) Autocomplete just html-encodes my theming. All tags like <b>, <span> are being printed to the user instead of displaying the actual styling.

So the suggestions now look like:

  • <b>su<b>suggestion
  • another <b>su<b>suggestion

instead of:

  • suggestion
  • another suggesion

I've read about custom data, but I use Yii framework and the output is being generated from certain actions (PHP code).

So, how do I theme the output now?

Thank you!

Denny J.
  • 249
  • 1
  • 2
  • 8
  • This is a duplicate question, sorry. http://stackoverflow.com/questions/3488016/using-html-in-jquery-ui-autocomplete – Denny J. Dec 31 '10 at 23:19

2 Answers2

0

You can use open function from jQuery UI to replace the encoded text.

Here's an example:

$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
                'name'=>"bug",
                'source'=>$this->createUrl('/autocomplete'),

                // additional javascript options for the autocomplete plugin

            'options'=>array(                       
                    'open'=> 'js:function(event, ui){
                      $("ul.ui-autocomplete li a").each(function(){
                      var htmlString = $(this).html().replace(/&lt;/g, "<");
                      htmlString = htmlString.replace(/&gt;/g, ">");
                      $(this).html(htmlString);
                      });
                    }'
            ),
));
random
  • 9,774
  • 10
  • 66
  • 83
L1v1u
  • 169
  • 3
0

Better use a HTML plugin

Denis Nikolaenko
  • 250
  • 2
  • 13