ui自动完成选择事件未在鼠标单击时触发 [英] ui autocomplete select event not fired on mouse click

查看:68
本文介绍了ui自动完成选择事件未在鼠标单击时触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,



i我正在使用JQuery UI v1.11.0



我的自动完成工作正常,除了这种情况:



当我点击一个菜单项时,select事件永远不会被触发,除非我完全点击该项目中的文本..仅然后点击该项目,然后点击选择



这里是我创建自动完成的代码:

dear all,

i am using JQuery UI v1.11.0

my autocomplete is working fine, except this case :

when i click on a menu item, "select" event is never fired, unless i click exactly on the text within the item.. only then the item is clicked, and "select" is fired

here is my code for creating autocomplete:

function CreateAutoComplete(sourceArray, labelTextBox, idTextBox) {

    $("#" + labelTextBox).autocomplete({ source: sourceArray,

        open: function (event, ui) {

            $(this).autocomplete("widget").find(".ui-menu-item").css({ "width": "300px" });
          
            $(this).autocomplete("widget").find(".ui-menu-item").bgiframe();

        },

 
        focus: function (event, ui) {
          
            $("#" + labelTextBox).val(ui.item.label);
            $("#" + idTextBox).val(ui.item.value);
            return false;
        },

        change: function (event, ui) {
            if (ui.item == null) {
                $("#" + labelTextBox).val("");
                $("#" + idTextBox).val("");
            }
        },

        select: function (event, ui) {
            $("#" + labelTextBox).val(ui.item.label);
            $("#" + idTextBox).val(ui.item.value);
            return false;
        } 

    });

    
   
} // function







如果我注释掉这一行,自动完成工作正常,点击鼠标就会触发选择:






if i comment out this line, autocomplete works fine, and "select" is fired on mouse click:

$(this).autocomplete("widget").find(".ui-menu-item").bgiframe();





但我需要这一行来解决IE6上自动完成的z-index问题...









thanx



but i need this line to solve the z-index issue of autocomplete on IE6...




thanx

推荐答案

+ labelTextBox).autocomplete({source:sourceArray,

open: function (event,ui){
("#" + labelTextBox).autocomplete({ source: sourceArray, open: function (event, ui) {


this )。autocomplete( widget)。find( 。ui-menu-ite m)。css({ width 300px});
(this).autocomplete("widget").find(".ui-menu-item").css({ "width": "300px" });


this )。autocomplete( widget)。find( 。ui-menu-item)。bgiframe();

},


焦点: function (event,ui){
(this).autocomplete("widget").find(".ui-menu-item").bgiframe(); }, focus: function (event, ui) {


这篇关于ui自动完成选择事件未在鼠标单击时触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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