简体   繁体   English

点击建议时阻止最新的Twitter类型关闭?

[英]Prevent latest Twitter typeahed from closing when clicking on a suggestion?

Before flagging this question as duplicate please note I've checked out all of these links and none work with the latest version v0.11.1: 在将此问题标记为重复之前,请注意我已检查了所有这些链接,但没有一个与最新版本v0.11.1一起使用:

My typeahed contains a form with an input. 我的打字包含一个带输入的表单。 I need to not to close the dropdown when user click a suggestion. 当用户点击建议时,我不需要关闭下拉列表。

Is there a reliable way to prevent close? 是否有可靠的方法来防止关闭? The obvious way it's not working ( https://jsfiddle.net/gcgdqfxp/ ): 显而易见的是它不起作用( https://jsfiddle.net/gcgdqfxp/ ):

$('.typeahed').on('typeahead:select', function (event, obj) {
    // not working
    event.preventDefault();

    // not working
    return false;
});

typeahead:select – Fired when a suggestion is selected. typeahead:select - 选择建议时触发。 The event handler will be invoked with 2 arguments: the jQuery event object and the suggestion object that was selected. 将使用2个参数调用事件处理程序:jQuery事件对象和所选的建议对象。

Yeah!!! 是啊! Found a solution looking at the source here the (undocumented) "typeahead:beforeselect" event is triggered before actually trigger the "typeahead:select", so it's easy to stop propagation ( https://jsfiddle.net/gcgdqfxp/2/ ) like: 找到一个查看源代码的解决方案这里 (未记录的)“typeahead:beforeselect”事件在实际触发“typeahead:select”之前触发,因此很容易停止传播( https://jsfiddle.net/gcgdqfxp/2/ )喜欢:

$('.typeahead').bind('typeahead:beforeselect', function (event) {
    event.preventDefault();
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在浏览器上单击任意位置时,防止daterangepicker关闭 - Prevent daterangepicker from closing when clicking anywhere on browser 基础-防止单击选择标记时关闭下拉列表 - Foundation - Prevent dropdown from closing when clicking a select tag 单击链接时防止jquery fancybox关闭 - Prevent jquery fancybox from closing when clicking on link 防止在外部单击时jQuery自动完成功能关闭搜索结果框 - Prevent jquery autocomplete from closing the search result box when clicking outside 在下拉菜单中单击时,如何防止它关闭? - How do I prevent my dropdown from closing when clicking inside it? jQuery自动完成功能-防止在外部div上单击时将其关闭? - jquery autocomplete - prevent closing it when clicking on outside div? jQuery Datepicker:单击日期时阻止关闭选择器 - jQuery Datepicker: Prevent closing picker when clicking a date 单击第一个菜单项后防止 MDC 菜单关闭 - Prevent MDC Menu from closing after clicking first menu item 有没有办法可以防止在点击日期选择器之外的已知容器时关闭kendo datepicker日历弹出窗口? - Is there a way I can prevent a kendo datepicker calendar pop-up from closing when clicking on a known container which is outside of the datepicker? 单击时模态关闭 - Modal Closing When Clicking It
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM