From 219ac567ebf3fdfcd06514e60f811337e495d4c0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Tue, 27 Jan 2015 11:47:53 +0100 Subject: [PATCH] =?utf8?q?kivi.js:=20popup=5Fdialog=20unterst=C3=BCtzt=20j?= =?utf8?q?etzt=20auch=20params.html?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- js/kivi.js | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/js/kivi.js b/js/kivi.js index 6ef7df7b2..b04a88cfa 100644 --- a/js/kivi.js +++ b/js/kivi.js @@ -174,9 +174,9 @@ namespace("kivi", function(ns) { // Open a modal jQuery UI popup dialog. The content can be either // loaded via AJAX (if the parameter 'url' is given) or simply // displayed if it exists in the DOM already (referenced via - // 'id'). If an existing DOM div should be used then the element - // won't be removed upon closing the dialog which allows re-opening - // it later on. + // 'id') or given via param.html. If an existing DOM div should be used then + // the element won't be removed upon closing the dialog which allows + // re-opening it later on. // // Parameters: // - id: dialog DIV ID (optional; defaults to 'jqueryui_popup_dialog') @@ -196,10 +196,10 @@ namespace("kivi", function(ns) { // User supplied options: params.dialog || { }, { // Options that must not be changed: - close: function(event, ui) { if (params.url) dialog.remove(); else dialog.dialog('close'); } + close: function(event, ui) { if (params.url || params.html) dialog.remove(); else dialog.dialog('close'); } }); - if (!params.url) { + if (!params.url && !params.html) { // Use existing DOM element and show it. No AJAX call. dialog = $('#' + id) @@ -215,15 +215,20 @@ namespace("kivi", function(ns) { dialog = $('').appendTo('body'); dialog.dialog(dialog_params); - $.ajax({ - url: params.url, - data: params.data, - type: params.type, - success: function(new_html) { - dialog.html(new_html); - dialog.removeClass('loading'); - } - }); + if (params.html) { + dialog.html(params.html); + } else { + // no html? get it via ajax + $.ajax({ + url: params.url, + data: params.data, + type: params.type, + success: function(new_html) { + dialog.html(new_html); + dialog.removeClass('loading'); + } + }); + } return true; }; -- 2.20.1