【问题标题】:typeahead after select option from autocomplete change input box从自动完成更改输入框中选择选项后提前输入
【发布时间】:2017-09-27 09:21:10
【问题描述】:

我正在实现 typeahead 自动完成选择,点击下拉选项后,将框从 From 更改为 To 但是当我选择使用 Enter 键 的下拉选项不会像上面那样更改框。

我的输入框是这样的,代码如下:

请告诉我该怎么办?

From: <input type="text" name="from" autocomplete="off" class="form-control inputTxtLarge inputSrc typeahead tt-query" placeholder="From: City or Airport" id="from_city" value="Delhi (India) DEL" spellcheck="false" required>

To: <input type="text" name="to" autocomplete="off" id="go_dest" class="form-control inputTxtLarge inputDest typeahead tt-query" placeholder="To: City or Airport" spellcheck="false" required>

用于将 From 更改为 To

的 javaScript 函数
$(document).on('click', '.tt-selectable', function(){
    $( "#go_dest" ).focus();
});

【问题讨论】:

  • 如何调用 typeahead 函数 - 请显示您的代码,以及您使用的是哪个版本的 typeahead?
  • 代码较长,无法在注释框中显示代码,版本为0.11.1
  • 我的意思只是调用 - $("....").typeahead ....

标签: javascript html codeigniter autocomplete typeahead.js


【解决方案1】:

Typeahead 有几个事件用于这个 - 这里是一个 jquery 示例

var objTypeahead = $("#domobject").typeahead();
objTypeahead.on("typeahead:select", function(e, suggestionObject)
{
    console.log(suggestionObject);
});

您可以找到完整的活动列表here

【讨论】:

    猜你喜欢
    • 2012-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-09
    • 2014-02-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多