From: Sven Schöling Date: Tue, 27 Jan 2015 10:47:53 +0000 (+0100) Subject: kivi.js: popup_dialog unterstützt jetzt auch params.html X-Git-Tag: release-3.2.0beta~30 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=219ac567ebf3fdfcd06514e60f811337e495d4c0;p=kivitendo-erp.git kivi.js: popup_dialog unterstützt jetzt auch params.html --- 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; };