jQuery TokenInput:令牌未添加 [英] jQuery TokenInput : Tokens are not getting added
问题描述
我正在使用jQuery TokenInput,它调用用node.js编写的服务.该服务给了我答复. (我已将其记录在onResult
和resultsFormatter
中.)但是没有显示令牌的下拉列表.
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");
}
});
响应已按预期记录在onResult
和resultsFormatter
中.我试图将其记录在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-dropdown
的token-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屋!