- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
请在此处请求健全性检查...
ExtJS 4.2 组合框 Typeahead 可以工作,但在以下条件下检索 valueField 时出现问题:-
1) 如果用户键入一个值,然后单击其他位置而不是按 Enter 键或单击选择组合列表,则 valueField 为空,但会出现所选值。
2)假设组合框项目被正确选择,如果我输入一个附加字符然后退格该字符,组合框将无法再找到 valueField..它几乎就像重置了自己一样。
fiddle 示例
<强> https://fiddle.sencha.com/#fiddle/je1
如何重现
如果在组合框中输入 Maggie,您将在控制台窗口中看到 valueField ID,如果追加一个字符然后退格该字符,则控制台窗口中的 ID 为空
(您需要打开控制台窗 Eloquent 能查看输出)
forceSelection 无法解决此问题,因为我有一个模板,并且它不接受组合框中不属于商店的条目,并且我需要对 valueField 使用 sumID,因为我需要检索并传递该值到服务器。
最佳答案
谢谢大家,拥有如此出色的社区真是太棒了!
我能够通过使用forceSelection并覆盖setValue来解决这个问题,从而允许通过forceSelection选择不在商店中但在组合中的模板项。在我看来,从使用组合框开始,为了获得良好的外观和感觉,forceSelection 是最佳选择。
这是我的覆盖,请参阅语句//覆盖开始
这是一个快速修复,当我回到办公室时我会完善陈述,下面我将我凭内存粘贴的解决方案,你明白了。
setValue: function(value, doSelect) {
var me = this,
valueNotFoundText = me.valueNotFoundText,
inputEl = me.inputEl,
i, len, record,
dataObj,
matchedRecords = [],
displayTplData = [],
processedValue = [];
if (me.store.loading) {
// Called while the Store is loading. Ensure it is processed by the onLoad method.
me.value = value;
me.setHiddenValue(me.value);
return me;
}
// This method processes multi-values, so ensure value is an array.
value = Ext.Array.from(value);
// Loop through values, matching each from the Store, and collecting matched records
for (i = 0, len = value.length; i < len; i++) {
record = value[i];
if (!record || !record.isModel) {
record = me.findRecordByValue(record);
}
// record found, select it.
if (record) {
matchedRecords.push(record);
displayTplData.push(record.data);
processedValue.push(record.get(me.valueField));
}
// record was not found, this could happen because
// store is not loaded or they set a value not in the store
else {
//start of override
// 'Select All Names' is the template item that was added // to the combo box, it looks like an entry from the store
// but it is not in the store
if (me.forceSelection && me.getDisplayValue() === 'Select All Names'){
processedValue.push(value[i]);
dataObj = {};
dataObj[me.displayField] = value[i];
displayTplData.push(dataObj);
}
//end of override
if (!me.forceSelection) {
processedValue.push(value[i]);
dataObj = {};
dataObj[me.displayField] = value[i];
displayTplData.push(dataObj);
// TODO: Add config to create new records on selection of a value that has no match in the Store
}
// Else, if valueNotFoundText is defined, display it, otherwise display nothing for this value
else if (Ext.isDefined(valueNotFoundText)) {
displayTplData.push(valueNotFoundText);
}
}
}
// Set the value of this field. If we are multiselecting, then that is an array.
me.setHiddenValue(processedValue);
me.value = me.multiSelect ? processedValue : processedValue[0];
if (!Ext.isDefined(me.value)) {
me.value = null;
}
me.displayTplData = displayTplData; //store for getDisplayValue method
me.lastSelection = me.valueModels = matchedRecords;
if (inputEl && me.emptyText && !Ext.isEmpty(value)) {
inputEl.removeCls(me.emptyCls);
}
// Calculate raw value from the collection of Model data
me.setRawValue(me.getDisplayValue());
me.checkChange();
if (doSelect !== false) {
me.syncSelection();
}
me.applyEmptyText();
return me;
},
关于javascript - ComboBox typeAhead 可以工作,但 valueField 在某些行为条件下为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28979652/
在我的 html 页面中,我尝试添加 Typeahead 以进行自动完成,但我无法解决与 TypeError 和 ReferenceError 相关的问题。 我在 CodePen 上尝试了一个示例,工
我已经使用 npm 安装了 typeahead.js。根据我的阅读,这包括预输入和猎犬。 然后我在我的模块中需要 jquery 之后需要它。 但现在当我打电话 new Bloodhound() Blo
我正在尝试使用Twitter提前输入,但遇到了问题。我不知道如何提前将字符串传递给服务器。是通过GET参数吗?如果是这样,该参数的名称是什么? 最佳答案 通过GET参数最简单,您可以选择所需的任何参数
看起来 CSS 不适用于我的 Typeahead。 我正在尝试重现可滚动下拉菜单,例如 https://twitter.github.io/typeahead.js/examples 这是我的代码:
我正在这样设置 typeahead: $this.typeahead({ prefetch: $this.data('url-prefetch'),
我有一个 Typeahead 实例拉入一个列出机场的远程 JSON 对象,我需要按“位置组”将它们分组到建议中,如下图所示: ...这里是如何格式化 JSON 的示例: { "locations
作为标题,我想问:“是否可以限制预先输入显示的建议?” 例如,我有 3 个数据集,每个数据集有 10000 个结果(来自查询)。主题以字符 t 开头大约有 3000 个结果或可能更多。 如果我输入 t
我想实现的功能是,如果我点击一个 DOM 元素,它会自动填充其中包含指定值的预先输入,它应该为此触发 typeahead:selected。 我发现了很多与之相关的查询,答案是 jQuery#type
首先,请检查:http://ws.luyencong.net/data/search/query.php?do=advanced 您可以将该 JSON 的所有内容粘贴到此处:http://pro.js
我一直在尝试结合几个功能 in typeahead plugin特别是多数据集 + 空 + 默认建议。到目前为止没有运气,希望有人可以帮助 现在,为了使其工作,它是多个数据集之间的选择---或---空
我正在尝试将预输入结果放入页面上的特定 div 中。我获得了 JSON 回调数据,但我不知道如何使用它来填充特定的 div。 process 函数的唯一作用是在搜索字段下方列出结果,无论其长度如何。
正如在 screenshot - 使用 typeahead 时如何禁用自动填充? 谢谢。 附注: 使用的浏览器是 Chrome 版本 47.0.2526.106(64 位) 最佳答案 添加 autoc
正如在 screenshot - 使用 typeahead 时如何禁用自动填充? 谢谢。 附注: 使用的浏览器是 Chrome 版本 47.0.2526.106(64 位) 最佳答案 添加 autoc
我使用的是 0.11.1 版的 Twitter Typeahead。现在我正试图让远程工作正常,但不知何故我认为我的行为很奇怪。 这是使用本地数组的工作代码: var localArray = [{"
我试过在 web 应用程序中应用 twitters typeahead 插件。我使用 typeahead 插件初始化了许多 typeahead 输入字段,这似乎以某种方式起作用。该插件栩栩如生。然而,
所以我使用Materialziecss和第三方库进行标签输入 Materializecss:http://materializecss.com/ Materialize 标签库:http://henr
我想用 Typeahead JS 做一个简单的自动完成但我不能让它工作。我按照手册中的说明进行操作,但我不确定我在这里做错了什么。我无法从 json 文件中获取正确的值。它是一个带有对象的数组,我只想
我有一个 Angular uib-typeahead。这是我创建的 plunkr 的链接。 https://plnkr.co/edit/8XwhSXsZlyd0oKSljS9t?p=preview .
我实际上想发送我选择的主题(一个包含许多变量的 json 对象),而不是存储在 topicsPopulate 中的字符串(主题名称)。Topics 是一个主题数组,一个主题看起来像这样, {
我正在尝试使用带有 react-bootstrap-typeahead 的旧 jQuery typeahead 来复制搜索字段。它查询使用多个异步数据源,并显示按这些数据源的返回分组的结果。 例如,如
我是一名优秀的程序员,十分优秀!