From: David ‘Bombe’ Roden Date: Sun, 14 Nov 2010 14:48:15 +0000 (+0100) Subject: Add function to ajaxify a notification. X-Git-Tag: 0.3-RC1~80 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=2e6247ae5b4abb156e54328cdb63c1b1363aae0a Add function to ajaxify a notification. --- diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 01c04a1..4ab0aab 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -407,3 +407,22 @@ function getReply(replyId, callbackFunction) { } }); } + +/** + * Ajaxifies the given notification by replacing the form with AJAX. + * + * @param notification + * jQuery object representing the notification. + */ +function ajaxifyNotificationArea(notification) { + notification.find("form.dismiss").submit(function() { + return false; + }); + notification.find("form.dismiss button").click(function() { + $.getJSON("ajax/dismissNotification.ajax", { "formPassword" : getFormPassword(), "notification" : notification.attr("id") }, function(data, textStatus) { + if (data.success) { + notification.slideUp(); + } + }); + }); +}