Revision 219ac567
Von Sven Schöling vor fast 10 Jahren hinzugefügt
js/kivi.js | ||
---|---|---|
174 | 174 |
// Open a modal jQuery UI popup dialog. The content can be either |
175 | 175 |
// loaded via AJAX (if the parameter 'url' is given) or simply |
176 | 176 |
// displayed if it exists in the DOM already (referenced via |
177 |
// 'id'). If an existing DOM div should be used then the element
|
|
178 |
// won't be removed upon closing the dialog which allows re-opening
|
|
179 |
// it later on. |
|
177 |
// 'id') or given via param.html. If an existing DOM div should be used then
|
|
178 |
// the element won't be removed upon closing the dialog which allows
|
|
179 |
// re-opening it later on.
|
|
180 | 180 |
// |
181 | 181 |
// Parameters: |
182 | 182 |
// - id: dialog DIV ID (optional; defaults to 'jqueryui_popup_dialog') |
... | ... | |
196 | 196 |
// User supplied options: |
197 | 197 |
params.dialog || { }, |
198 | 198 |
{ // Options that must not be changed: |
199 |
close: function(event, ui) { if (params.url) dialog.remove(); else dialog.dialog('close'); } |
|
199 |
close: function(event, ui) { if (params.url || params.html) dialog.remove(); else dialog.dialog('close'); }
|
|
200 | 200 |
}); |
201 | 201 |
|
202 |
if (!params.url) { |
|
202 |
if (!params.url && !params.html) {
|
|
203 | 203 |
// Use existing DOM element and show it. No AJAX call. |
204 | 204 |
dialog = |
205 | 205 |
$('#' + id) |
... | ... | |
215 | 215 |
dialog = $('<div style="display:none" class="loading" id="' + id + '"></div>').appendTo('body'); |
216 | 216 |
dialog.dialog(dialog_params); |
217 | 217 |
|
218 |
$.ajax({ |
|
219 |
url: params.url, |
|
220 |
data: params.data, |
|
221 |
type: params.type, |
|
222 |
success: function(new_html) { |
|
223 |
dialog.html(new_html); |
|
224 |
dialog.removeClass('loading'); |
|
225 |
} |
|
226 |
}); |
|
218 |
if (params.html) { |
|
219 |
dialog.html(params.html); |
|
220 |
} else { |
|
221 |
// no html? get it via ajax |
|
222 |
$.ajax({ |
|
223 |
url: params.url, |
|
224 |
data: params.data, |
|
225 |
type: params.type, |
|
226 |
success: function(new_html) { |
|
227 |
dialog.html(new_html); |
|
228 |
dialog.removeClass('loading'); |
|
229 |
} |
|
230 |
}); |
|
231 |
} |
|
227 | 232 |
|
228 | 233 |
return true; |
229 | 234 |
}; |
Auch abrufbar als: Unified diff
kivi.js: popup_dialog unterstützt jetzt auch params.html