X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/6ca2197818029fad5253edd8f08988ddc66aa359..3f4f01dcd306d7ebb51a1186d722e6aecd237003:/scripts/generate_client_js_actions.tpl diff --git a/scripts/generate_client_js_actions.tpl b/scripts/generate_client_js_actions.tpl index 6572e22c3..46032667f 100644 --- a/scripts/generate_client_js_actions.tpl +++ b/scripts/generate_client_js_actions.tpl @@ -4,10 +4,23 @@ // "scripts/generate_client_js_actions.pl". See the documentation for // SL/ClientJS.pm for instructions. +function display_flash(type, message) { + $('#flash_' + type + '_content').text(message); + $('#flash_' + type).show(); +} + function eval_json_result(data) { if (!data) return; + if (data.error) + return display_flash('error', data.error); + + $(['info', 'warning', 'error']).each(function(idx, category) { + $('#flash_' + category).hide(); + $('#flash_' + category + '_content').empty(); + }); + if ((data.js || '') != '') eval(data.js); @@ -20,3 +33,13 @@ function eval_json_result(data) { // console.log("current_content_type " + $('#current_content_type').val() + ' ID ' + $('#current_content_id').val()); } + +function submit_ajax_form(url, form_selector, additional_data) { + var separator = /\?/.test(url) ? '&' : '?'; + $.post(url + separator + $(form_selector).serialize(), additional_data, eval_json_result); + return true; +} + +// Local Variables: +// mode: js +// End: