创建Jquery UI对话框并移动到顶部

时间:2016-11-07 13:13:02

标签: javascript jquery jquery-ui

我创建了一个简单的Jquery UI对话框,并希望将它放在前面。

Dim correctSheet as Worksheet
correctSheet = Worksheets("SheetName")
correctSheet.Unprotect ' etc..

我收到此错误 var dialog = $(document.createElement("div")); dialog.attr("id","dialog-confirm"); $( "body" ).append(dialog); $( "#dialog-confirm" ).dialog({ resizable: false, height: "auto", width: 400, buttons: { "Delete all items": function() { $( this ).dialog( "close" ); }, Cancel: function() { $( this ).dialog( "close" ); } } }); dialog.dialog("moveToTop");

我该怎么办?

1 个答案:

答案 0 :(得分:0)

从技术上讲,您不必将其附加到身体上。以下代码将起作用:

$(function() {
  var dialog = $("<div>", {
    id: "dialog-confirm"
  }).dialog({
    resizable: false,
    height: "auto",
    width: 400,
    buttons: {
      "Delete all items": function() {
        $(this).dialog("close");
      },
      Cancel: function() {
        $(this).dialog("close");
      }
    }
  });
  dialog.dialog("moveToTop");
});

只有在一次打开多个对话框时才需要moveToTop