【发布时间】:2010-06-26 18:24:47
【问题描述】:
我有这个测试代码,除了在对话框第二次打开时自动完成停止工作之外,它运行良好。我需要使用 html 以这种方式打开对话框,因为我希望它打开得非常快,这是最好的方法。为什么自动完成第二次停止工作?
var $container = $('#container'),
$input = $container.find('input:eq(0)');
var source = new Array(2);
source[0] = { value: 1000, label: 'Description' };
source[1] = { value: 1001, label: 'Description' };
$input.autocomplete({ source: source });
var $dialog = $('<div></div>').dialog({
autoOpen: false,
modal: true,
beforeclose: function() { $dialog.html(''); }
});
$('#open').click(function() {
$dialog.dialog('open').html($container);
});
编辑:我这样使用 html 的原因是因为我想打开一个空对话框来加速它。这样做会使对话框看起来更具响应性。我想继续以这种方式打开对话框。谜团仍然存在,为什么事件处理程序和自动完成在我第二次以这种方式打开对话框时停止工作? $container 或 $input 没有任何变化。
【问题讨论】:
标签: jquery jquery-ui autocomplete dialog