JQuery UI自动完成 - 为每个结果项添加操作链接 [英] JQuery UI Autocompletion - Adding a action link to each result item

查看:125
本文介绍了JQuery UI自动完成 - 为每个结果项添加操作链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以这种方式在jquery UI自动完成组件中修改我的结果列表,我实现了以下目的:

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

label resul_text actionlink

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?

感谢您的想法,
Ramo

Thank you for your thoughts, Ramo

推荐答案

假设您想对页面上的所有自动完成组件执行此操作,我将修改_renderItem属性。它是一个由jquery UI调用的函数,用于呈现列表中向结果显示给用户的每个项目。

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);
};

这篇关于JQuery UI自动完成 - 为每个结果项添加操作链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆