diff --git a/public/src/modules/notifications.js b/public/src/modules/notifications.js index f1c0541723..2d150379a2 100644 --- a/public/src/modules/notifications.js +++ b/public/src/modules/notifications.js @@ -17,7 +17,7 @@ define(function() { numUnread = data.unread.length, x; - notifList.html(''); + var html = ''; if (!err && (data.read.length + data.unread.length) > 0) { var image = ''; @@ -27,7 +27,7 @@ define(function() { } else { image = ''; } - notifList.append($('
  • ' + image + '' + utils.relativeTime(data.unread[x].datetime, true) + '' + data.unread[x].text + '
  • ')); + html += '
  • ' + image + '' + utils.relativeTime(data.unread[x].datetime, true) + '' + data.unread[x].text + '
  • '; } for (x = 0; x < numRead; x++) { @@ -36,18 +36,27 @@ define(function() { } else { image = ''; } - notifList.append($('
  • ' + image + '' + utils.relativeTime(data.read[x].datetime, true) + '' + data.read[x].text + '
  • ')); + html += '
  • ' + image + '' + utils.relativeTime(data.read[x].datetime, true) + '' + data.read[x].text + '
  • '; } + addSeeAllLink(replaceHtml); } else { translator.translate('
  • [[notifications:no_notifs]]
  • ', function(translated) { - notifList.append($(translated)); + html += translated; + addSeeAllLink(replaceHtml); }); } - translator.translate('', function(translated) { - notifList.append($(translated)); - }); + function addSeeAllLink(callback) { + translator.translate('', function(translated) { + html += translated; + callback(); + }); + } + + function replaceHtml() { + notifList.html(html); + } updateNotifCount(data.unread.length);