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>")
																			.appendTo(ul);

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.

Recommended Answers

All 7 Replies

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?

Why don't you just use the echo() function instead of an api?

I need to loop that result by autocomplete function

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.