Hi Guys,

Yii::app()->clientScript->registerScript('highlightAC','$.ui.autocomplete.prototype._renderItem = function (ul, item) {																			
																			return $("<li></li>")
																			.data("item.autocomplete", item)
																			.append("<a><img src=\"'.$Image.'\" border=\"0\" width=\"25px\" height=\"25px\"/> " + item.label + "</a>")

BY refering the above code, I wish to attach my image into an autocomplete search bar where each result will have different image depend on searching append to.But i m stuck where the image is same after I search item. Any1 know what is happening.it is looping with the same image..that is Not what I want.

5 Years
Discussion Span
Last Post by Stefan_Lam88

Could you please describe with more detail what exactly the problem is because that made no sense at all. Also note that php variables are case sensitive meaning that $Image must have a capital "I" when using all the time.


example I query a list of 10 items. my image wish to show in the search bar, autocomplete.

example u type a, it will show item start with a...but I WANT to ADD image append to this result. The result showing is not matched.Because it just show same image of 10 list items.


i WISH to know how to append image in the above code..because I think suppose image is attached here but wish to have a looping there, is it possible?


Well I'm not familiar with YII as I do not recommend using external frameworks or api's as the core of your code. But if you were to translate that into raw php code I would imagine it would be something like the following.

foreach ($item->autocomplete AS $item) {
echo "<a><img src=\"'.$Image.'\" border=\"0\" width=\"25px\" height=\"25px\"/> ". ($item->label).'</a>';

But that is that equivalent of not using the framework you've provided.


Thanks for your reply. i m still cant figure out the solution. Any pro Yii developer?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.