追加一个项目一个jQuery用户界面自动完成 [英] Appending an item to a jQuery UI autocomplete

查看:166
本文介绍了追加一个项目一个jQuery用户界面自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我使用的是引用一个ASHX文件的文本框jQuery用户界面自动完成。

Currently, I'm using jQuery UI autocomplete on a textbox that references an ASHX file.

一切工作propertly,但我想在读取列表的末尾追加项目:找不到项目按此要求添加一个新的项目。

Everything is working propertly, except I want to append an item at the end of the list that reads: "Item not found? Click here to request to add a new item."

我试过code以下的线,但是它所作的只是格式项目的,我无法追加。

I tried the following the lines of code, but all it did was format the item's, I was unable to append.

data( "catcomplete" )._renderItem = function( ul, item ) {
        return $( "<li></li>" )
            .data( "item.catcomplete", item )
            .append( $( "<a class='ui-menu-item'></a>" ).text( item.label ) )
            .appendTo( $('ul').last('.autocomplete-category'));
    };

提示?提示? MUCHO格拉西亚斯! :D

Hints? Tips? Mucho gracias! :D

推荐答案

您应该在 添加额外的条目打开事件火灾。这会给你访问到列表中,这是你所追求的,而不是每一个元素,这是你获得什么 _renderItem 所赐。

下面是一个例子造型已经被填充到列表中的条目:

Here's an example styling the entries that have been populated into the list:

$("#myBox").autocomplete({
        source: "[URL]",
        minLength: 2,
        open: function(event, ui) {
            $("ul.ui-autocomplete.ui-menu .ui-menu-item:odd").css("background-color","#dedede");
        }
    });

这篇关于追加一个项目一个jQuery用户界面自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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