【发布时间】:2012-01-10 22:32:45
【问题描述】:
我有一个 Ruby 和 Rails 应用程序。
我正在使用 Ajax 加载表单。该表单是现有的 Rails 视图。该表单又包含 jQueryUi 选项卡。
不幸的是,当表单加载到 jQuery 对话框中时,选项卡没有显示。
这是对话框的代码
$('#create_candidate').click( function(e) {
var url = $(this).attr('href').replace('?','.js?');
var new_candidate_dlg = $('<div id="new_candidate_dlg">Loading form ...</div>');
new_candidate_dlg.load(url);
new_candidate_dlg.dialog({
autoOpen:false,
width: 'auto',
height: 'auto',
modal: true,
close: function() {
$('new_candidate_dlg').remove();
},
open: function() {
$('#tabs').tabs();
}
});
new_candidate_dlg.dialog('open');
e.preventDefault();
});
奇怪的是,如果我像下面这样更改代码,标签确实会出现,但只有当我点击标签时才会出现。
$('#create_candidate').click( function(e) {
var url = $(this).attr('href').replace('?','.js?');
var new_candidate_dlg = $('<div id="new_candidate_dlg">Loading form ...</div>');
new_candidate_dlg.load(url);
new_candidate_dlg.dialog({
autoOpen:false,
width: 'auto',
height: 'auto',
modal: true,
close: function() {
$('new_candidate_dlg').remove();
},
open: function() {
$('#tabs').live('click', function (){
$(this).tabs()
});
}
});
new_candidate_dlg.dialog('open');
e.preventDefault();
});
【问题讨论】:
标签: jquery ruby-on-rails jquery-ui