我正在使用 jquery UI 对话框根据单击的内容显示注释或其他文本。
这是我的 JSfiddle 链接对话演示 http://jsfiddle.net/brijesh26/6wMRe/3/
我已经使用了代码
$('.showComments').each(function () {
var panel = $(this).parent().siblings('.divCommentDetail');
$(this).click(function () {
panel.dialog('open');
});
});
$('.showContractChanges').each(function () {
var panel = $(this).parent().siblings('.divContractChangeDetail');
$(this).click(function () {
panel.dialog('open');
});
});
$(".divCommentDetail, .divContractChangeDetail").dialog({
autoOpen: false,
modal: true,
open: function () {
$(this).parent().siblings('.ui-dialog-titlebar').addClass('ui-state-error');
},
show: {
effect: 'blind',
duration: 1000
},
hide: {
effect: 'explode',
duration: 1000
}
});
并且内容是在页面加载时动态添加的。我正在尝试使用 $(document).on('each', '.showComments', function(e) {});这样它就可以处理动态加载的内容,但它根本不起作用。这是我修改后的代码。
$(document).on('each', '.showComments', function () {
var panel = $(this).parent().siblings('.divCommentDetail');
$(this).click(function () {
panel.dialog('open');
});
});
但这根本不起作用。难道我做错了什么。
谢谢您的帮助。