将焦点设置为jQuery UI MultiSelect Widget中的Filter输入 [英] Set focus to the Filter input in a jQuery UI MultiSelect Widget

查看:120
本文介绍了将焦点设置为jQuery UI MultiSelect Widget中的Filter输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个小脚本,它将焦点设置到多选jquery小部件的过滤器文本输入字段。根据文档,我可以订阅小部件的click事件,如下所示:

I am writing a small script which will set focus to the filter text input field of the multi select jquery widget. Based on the documentation, I can subscribe to the click event of the widget like this:

// bind to event
$("#multiselect").bind("multiselectopen", function(event, ui){
    // event handler here
});

所以我试过这个:

$("#MyStatusWidget").bind("multiselectopen", function(event, ui){
            // event handler here
            $(this).$(".ui-multiselect-filter").contents('input :text').focus());
        });

这是小工具的链接: http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/

我还尝试了其他一些方法($('')。is(':text');等),但无法获得钩子。

I also tried a couple other methods ($('').is(':text'); etc), but can't get the hook.

这是HTML:

<div class="ui-widget-header ui-corner-all ui-multiselect-header ui-helper-clearfix ui-multiselect-hasfilter">
<div class="ui-multiselect-filter">
Filter:
<input type="search" placeholder="Enter keywords">
</div>
<ul class="ui-helper-reset">
</div>

谢谢

推荐答案

创建多选小部件时,只需添加以下打开方法。

When you create your multi select widget simply add the following "open" method.

$("#MyStatusWidget").multiselect({
    open: function () {
        $("input[type='search']:first").focus();                   
    }
});

对于IE10 bowser:

For IE10 bowser:

$("#MyStatusWidget").multiselect({
    open: function () {
        $("input[type='text']:first").focus();                   
    }
});

这篇关于将焦点设置为jQuery UI MultiSelect Widget中的Filter输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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