From: Moritz Bunkus Date: Tue, 23 Apr 2013 12:42:13 +0000 (+0200) Subject: jQuery-Script/Methode zum Anstoßen von Downloads X-Git-Tag: release-3.1.0beta1~469 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=1c127236bd8d41997a8566651e9361623c308aa3;p=kivitendo-erp.git jQuery-Script/Methode zum Anstoßen von Downloads --- diff --git a/SL/Form.pm b/SL/Form.pm index 5af4dc287..d1d4315ca 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -475,7 +475,7 @@ sub header { ); $layout->use_javascript("$_.js") for (qw( - jquery jquery-ui jquery.cookie jqModal jquery.checkall + jquery jquery-ui jquery.cookie jqModal jquery.checkall jquery.download common part_selection switchmenuframe ), "jquery/ui/i18n/jquery.ui.datepicker-$::myconfig{countrycode}"); diff --git a/js/jquery.download.js b/js/jquery.download.js new file mode 100644 index 000000000..54ffb6afd --- /dev/null +++ b/js/jquery.download.js @@ -0,0 +1,19 @@ +jQuery.download = function(url, data, method) { + //url and data options required + if (!url || !data) + return; + + //data can be string of parameters or array/object + data = typeof data == 'string' ? data : jQuery.param(data); + //split params into form inputs + var form = jQuery('
'); + jQuery.each(data.split('&'), function(){ + var pair = this.split('='); + var input = jQuery(''); + input.attr('name', decodeURIComponent(pair[0])); + input.val(decodeURIComponent(pair[1])); + input.appendTo(form); + }); + //send request + form.appendTo('body').submit().remove(); +};