1
我正在使用自動填充窗口小部件,並希望在選擇某個項目時顯示對話框。該對話框顯示出來,但我想讓對話框中的一個字段在打開時獲得焦點。以下是我迄今爲止嘗試:jquery ui 1.7選擇自動完成顯示對話框
// HTML
<form action="#">
<p><input id="busca" /></p>
</form>
<div id="agregar" title="Agregar Parte">
<label for="cantidad">Cantidad:</label>
<input name="cantidad" id="cantidad" size="3" />
</div>
// jQuery的
$(function(){
$("#agregar").dialog({
autoOpen: false,
//also tried open: function(){$("#cantidad").focus()}
}
);
//.bind("dialogfocus", ...) does not work either
$("#agregar").bind("focus", function(){
$("#cantidad").focus(); });
$("#busca").autocomplete({
source: "/carrito/autocomplete/",
minLength: 1,
select: function(e, ui) {
$("#agregar").dialog("open");
}
});
});
我覺得自選的默認行爲,又是做什麼的自選小部件後獲得焦點會顯示對話框。
任何幫助將不勝感激。
非常感謝你,現在的工作。 – 2010-03-30 19:35:30