JQuery UI Autocompletion - Adding a action link to each result item

梦想的初衷 提交于 2019-12-13 07:53:46

问题


i would like to modify my resultlist in the jquery UI autocomplete component in such a way, that i achieve the following:

label resulting_text actionlink

Is that somehow possible or do i need to do some monkey-patching? If monkey-patching is the action, where do i get a resource to look how this can be modified?

Thank you for your thoughts, Ramo


回答1:


Assuming that you would like to do this for all the autocomplete components on the page, I'd modify the "_renderItem" property. It is a function that is called by jquery UI to render each of the items on the list that is shown to the user with the results.

I've done something similar to this in one of my projects. Here is the code I used:

$.ui.autocomplete.prototype._renderItem = function (ul, item) {
    return $('<li />').data('item.autocomplete', item).append('<a>' + item.toString().htmlEncode() + '</a>')
        .appendTo(ul);
};


来源:https://stackoverflow.com/questions/8467689/jquery-ui-autocompletion-adding-a-action-link-to-each-result-item

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!