我有这个测试代码,除了自动完成功能在第二次打开对话框时停止工作以外,完美地工作。我需要使用html以这种方式打开对话框,因为我希望它能够快速打开,这是最好的方式。为什么自动完成功能第二次停止工作?jQuery自动完成只在对话框中工作一次
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中没有任何更改。