Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 2f4069ab

Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt

  • ID 2f4069ab9948acec08b4a26527ae9261f4ca5234
  • Vorgänger ce221150
  • Nachfolger 83381f25

kivi.popup_dialog(): Unterstützung für bereits existierende DIVs

Damit muss kein AJAX-Call mehr gemacht werden, sondern man kann den
DIV initial versteckt rendern und dann beliebig oft
anzeigen (öffnen)/verstecken (schließen).

Unterschiede anzeigen:

js/kivi.js
59 59
    return namespace(parts[1])[ parts[2] ];
60 60
  };
61 61

  
62
  // Open a modal jQuery UI popup dialog. The content is loaded via AJAX.
62
  // Open a modal jQuery UI popup dialog. The content can be either
63
  // loaded via AJAX (if the parameter 'url' is given) or simply
64
  // displayed if it exists in the DOM already (referenced via
65
  // 'id'). If an existing DOM div should be used then the element
66
  // won't be removed upon closing the dialog which allows re-opening
67
  // it later on.
63 68
  //
64 69
  // Parameters:
65 70
  // - id: dialog DIV ID (optional; defaults to 'jqueryui_popup_dialog')
66
  // - url, data, type: passed as the first three arguments to the $.ajax() call
71
  // - url, data, type: passed as the first three arguments to the $.ajax() call if an AJAX call is made, otherwise ignored.
67 72
  // - dialog: an optional object of options passed to the $.dialog() call
68 73
  ns.popup_dialog = function(params) {
69 74
    var dialog;
......
79 84
        // User supplied options:
80 85
      params.dialog || { },
81 86
      { // Options that must not be changed:
82
        close: function(event, ui) { dialog.remove(); }
87
        close: function(event, ui) { if (params.url) dialog.remove(); else dialog.dialog('close'); }
83 88
      });
84 89

  
90
    if (!params.url) {
91
      // Use existing DOM element and show it. No AJAX call.
92
      dialog = $('#' + id).dialog(dialog_params);
93
      return true;
94
    }
95

  
85 96
    $('#' + id).remove();
86 97

  
87 98
    dialog = $('<div style="display:none" class="loading" id="' + id + '"></div>').appendTo('body');

Auch abrufbar als: Unified diff