多个对话框 - 定位彼此的每个偏移量

multiple dialogs - position each offset of each other

我正在使用对话框向公司内部网上的用户发送消息。我目前正在使用 jquery 对话框来显示消息。

var alerts = data.d;
$.each(alerts, function(index, notifier) {
    var divId = 'div' + index;
    var div = '<div id="' + divId + '">' + notifier.Message + '</div>';
    $('#alertPlaceHolder').append(div);
    $('#' + divId).dialog({
        width: 400,
        height: 250,
        modal: true,
        title: notifier.Title + ' [Alert Id # ' + notifier.AlertId + ']',
        show: 'slide',
        hide: 'explode',
        position: {
            my: "left top",
            at: "left top",
            of: 'window'
        },
        buttons: {
            'Ok': function() {
                $(this).dialog('close');
            }
        }
    });

});

如果有多条消息,当前会将每个对话框放在彼此之上。如何让对话框相互抵消 n。例如:

根据文档:

my (default: "center") Type: String Defines which position on the element being positioned to align with the target element: "horizontal vertical" alignment. A single value such as "right" will be normalized to "right center", "top" will be normalized to "center top" (following CSS convention). Acceptable horizontal values: "left", "center", "right". Acceptable vertical values: "top", "center", "bottom". Example: "left top" or "center center". Each dimension can also contain offsets, in pixels or percent, e.g., "right+10 top-25%". Percentage offsets are relative to the element being positioned.

所以你可以在 .each 中定义一个偏移变量,然后做类似

的事情

my: "left top + " + myOffSet 应该可以解决问题。