首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >无法使用HTML设置未定义的jQuery UI autocomplete的属性'_renderItem‘

无法使用HTML设置未定义的jQuery UI autocomplete的属性'_renderItem‘
EN

Stack Overflow用户
提问于 2012-03-01 16:57:35
回答 6查看 70.1K关注 0票数 72

我使用以下代码将我的HTML自动完成项呈现为jQuery。项目在自动完成控件中正确呈现,但我一直收到这个javascript错误,无法跳过它。

Firefox 无法转换JavaScript参数

Chrome 无法设置未定义的属性“”_renderItem“”

  donor.GetFriends(function (response) {
    // setup message to friends search autocomplete
    all_friends = [];
    if (response) {
        for (var i = 0; i < response.all.length - 1; i++) {                
                all_friends.push({
                    "label":"<img style='padding-top: 5px; width: 46px; height: 46px;' src='/uploads/profile-pictures/" +
                        response.all[i].image + "'/><br/><strong style='margin-left: 55px; margin-top: -40px; float:left;'>" +
                        response.all[i].firstname + " " + response.all[i].lastname + "</strong>",

                    "value":response.all[i].firstname + " " + response.all[i].lastname,
                    "id":response.all[i].user_id});
            }
        }        

    $('#msg-to').autocomplete({
        source:all_friends,
        select:function (event, ui) {               
            // set the id of the user to send a message to
            mail_message_to_id = ui.item.id;
        }

    }).data("autocomplete")._renderItem = function (ul, item) {
        return $("<li></li>")
            .data("item.autocomplete", item)
            .append($("<a></a>").html(item.label))
            .appendTo(ul);
    };
});

不知道它为什么抛出这个错误,或者我必须做什么才能通过it...Any帮助,我很感激。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9513251

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档