Javascript 如何在点击事件中打开JQuery UI组合框?
我试图在单击JQuery UI组合框时打开它,基本上我想要的是:Javascript 如何在点击事件中打开JQuery UI组合框?,javascript,jquery-ui,Javascript,Jquery Ui,我试图在单击JQuery UI组合框时打开它,基本上我想要的是: $("#auto").bind("focus", function () { this.value = ''; $(this).autocomplete("search", ''); }); 但是在一个组合框中 问题是,我无法获得焦点或单击要触发的事件 我尝试了单击并绑定焦点事件:实际字段,jquery创建的输入字段,但从那以后它们都不起作用 我怎样才能在JQueryUI组合框中工作 更新 我刚刚注意到,当我
$("#auto").bind("focus", function () {
this.value = '';
$(this).autocomplete("search", '');
});
但是在一个组合框中
问题是,我无法获得焦点或单击要触发的事件
我尝试了单击并绑定焦点事件:实际字段,jquery创建的输入字段,但从那以后它们都不起作用
我怎样才能在JQueryUI组合框中工作
更新
我刚刚注意到,当我打开选项并将鼠标悬停在选项上时,会触发事件。但我想再次触发它,当我点击输入部分
*代码*
剃刀代码
<div class="editor-label">
@Html.LabelFor(model => model.Lugar, "Nombre del Lugar")
</div>
<div class="editor-field">
@Html.DropDownList("Lugar", String.Empty)
@Html.ValidationMessageFor(model => model.Lugar)
</div>
事件
$("#Lugar").click(function () {
alert("Handler for .click() called.");
});
$("#Lugar-input").bind("focus", function ()
{
alert("a");
});
在单击事件中创建输入字段时添加对函数openMethod的调用
var input = this.input = $("<input>")
//.appendTo(wrapper)
.insertAfter( select )
.val(value)
.attr("title", "")
**.click(openmethod)**
var input = this.input = $("<input>")
//.appendTo(wrapper)
.insertAfter( select )
.val(value)
.attr("title", "")
**.click(openmethod)**
var openmethod = function () {
// close if already visible
if (input.autocomplete("widget").is(":visible")) {
input.autocomplete("close");
return;
}
// work around a bug (likely same cause as #5265)
$(this).blur();
// pass empty string as value to search for, displaying all results
input.autocomplete("search", "");
input.focus();
};