涉及搜索事件select事件后如何重新打开一个菜单? [英] How to re-open a menu after a select event that involves a search event?

查看:172
本文介绍了涉及搜索事件select事件后如何重新打开一个菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 jQuery的自动完成功能部件,经过一个不满意(至少对我来说) <一href=\"http://stackoverflow.com/questions/13542923/how-to-$p$pvent-closing-the-menu-after-a-select\">$p$pvious所涉及黑客插件,以prevent关闭菜单问题,我要寻找一个微创的方式让事情有不同的方法。所以,我想知道是否有办法的重新开启的一个事件之后的菜单,涉及搜索事件。即,给定的

I am using the jQuery Autocomplete widget and, after a "unsatisfactory" (at least for me) previous question that involved hacking the plugin in order to prevent closing the menu, I am looking for a "less invasive" way to make things with a different approach. So, I would like to know if there is a way to re-open the menu after a select event that involves a search event. That is, given

$(#input_field).autocomplete({
  autoFocus: true,
  select   : function(event, ui) {
    event.preventDefault();

    $(this).autocomplete('search', "Custom search string" );
  },
  ...
});

我想使菜单打开的(注意的:有是的之后,用户从菜单中选择一个项目的相对=nofollow>接近菜单,但不要打开它)。是否可以?如果是这样,怎么样?

I would like to make the menu to open (note: there is a method to close the menu but not to open it) after that the user select a item from that menu. Is it possible? If so, how?

推荐答案

我发现了一个办法做到这一点。用一个定时器来听自动完成关闭事件:

i found a way to do this . use a timer to listen autocomplete close event :

var stop = false;
setInterval(function(){
    if(!$('.ui-autocomplete').is(':visible') && !stop)
    {
        $('.ui-autocomplete').css('display','block');
    }
},10);

但是这并不是prevent关闭菜单好办法!!!!结果
你可以设置'停止'为真当一个事件发生了。

but this is not good way to prevent closing menu !!!!
you can set 'stop' to true when an event happen .

这篇关于涉及搜索事件select事件后如何重新打开一个菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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