DIV CSS 佈局教程網

EasyUI 二次彈窗:modalDialogTwo 的封裝思路
編輯:關於JavaScript     

在 EasyUI 中,若需要開啟第二層彈出式視窗,可以自行封裝一個 dialog 方法。重點是透過 handler 保留目前彈窗實例,避免重複開啟,並在關閉時清理資源。

$.modalDialogTwo = function(options) {
  if ($.modalDialogTwo.handler == undefined) {
    var opts = $.extend({
      title: '',
      width: 840,
      height: 680,
      modal: true,
      onClose: function() {
        $.modalDialogTwo.handler = undefined;
        $(this).dialog('destroy');
      }
    }, options);
    opts.modal = true;
    return $.modalDialogTwo.handler = $('<div/>').dialog(opts);
  }
};

這樣設計後,呼叫端只要決定標題、寬高與內容,就能快速開啟第二層視窗;關閉後也會自動釋放,不會殘留舊的 dialog 物件。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved