jQuery TokenInput:令牌未添加 [英] jQuery TokenInput : Tokens are not getting added

查看:69
本文介绍了jQuery TokenInput:令牌未添加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery TokenInput,它调用用node.js编写的服务.该服务给了我答复. (我已将其记录在onResultresultsFormatter中.)但是没有显示令牌的下拉列表.

I am using jQuery TokenInput which calls the service written in node.js. The service is giving me a response. (I have logged it in onResult and resultsFormatter.) But the drop down of tokens doesn't show up.

我的服务响应如下:

{
    "data": [
        {
            "name": "a",
            "key": 1023040,
            "subtext": "abc"
        },
        {
            "name": "b",
            "key": 1023040,
            "subtext": "pqr"
        }
    ]
}

JavaScript代码如下.

JavaScript code is as follows.

       $("#myInputTextBox").tokenInput('http://myWebService', {
            crossDomain: true,
            theme: "facebook",
            minChars: 3,
            resultsFormatter: function(item) { 
                console.log("<li><p class='added' data-id='" + 
                            item.key + "' data-name='" + item.originalName + 
                            "'>" + item.name + "</p></li>");
                return "<li><p class='added-cities' data-id='" + 
                item.key + "' data-name='" + item.originalName + 
                "'>" + item.name + "</p></li>" 
            }, 
            onResult: function (results) {
                 results = results["data"];
                 $.each(results, function (index, value) {
                        value.originalName = value.name;
                        value.id = value.key;
                        value.name = value.name + " " + value.subtext;
                 });
                console.log(results);
                return results;
            },
            onAdd: function(item) {
                console.log("addrd");
            }
        });

响应已按预期记录在onResultresultsFormatter中.我试图将其记录在onAdd中,但未记录.这是什么问题?

The response is getting logged in onResult as well as resultsFormatter as expected. I tried to log it in onAdd it doesn't get logged. What's the issue here?

推荐答案

此处的问题可能是由于在模态窗口中使用了TokenInput,下拉菜单的z-index为1,而模态窗口可能会更高.

The issue here is likely due to the face that the TokenInput is being used in a modal window, and the z-index of the dropdown is 1, whereas the modal window will likely be higher.

要解决此问题,应将div.token-input-dropdowntoken-input.css中的z-index值修改为高于模态值.

To fix this the z-index value in token-input.css for div.token-input-dropdown should be modified to be higher than the modal value.

这篇关于jQuery TokenInput:令牌未添加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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