/** * Shows a message. * * @param {String} html - the HTML code of the message */ function msg(html) { $(".msg").alert('close'); $(html).hide().appendTo("#msg-container").fadeIn("slow"); } /** * Shows an error message for failing ajax requests. */ function noConnection() { var html = $("
", { "class": "alert alert-error msg", "data-dismiss": "alert", "text": "Der Server ist nicht erreichbar. Die Aktion konnte nicht ausgeführt werden." }); $("

", { "text": "Fehler!" }).prependTo(html); msg(html); } $(document).ajaxError(function(e, jqxhr, settings, exception) { // attach error handler to all ajax requests except autocomplete if (settings.url.indexOf("autocomplete") != -1) { noConnection(); } }); /** * Shows an error message for a form control. * * @param {Object} data */ function error(data) { $('div[id$="-group"]').removeClass("error"); $('.help-inline').remove(); if (data.formErrors) { for (var i = 0; i < data.formErrors.length; i++) { var field = data.formErrors[i].field; var last = $("#" + field + "-group input:last"); $("#" + field + "-group").addClass("error"); $("", { "class": "help-inline", "text": data.formErrors[i].msg, }).appendTo("#" + field + "-group"); } } }