question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ajax update element with unread_count and max number of notifications to display

See original GitHub issue

Hi, I recently discover this awesome module but I have a few questions:

I saw that the json response with notifications contains: “unread_count”: 1 so I was wondering if it’s possible to update a count in a notification icon on top bar (like facebook globe and it’s count) with that response, or it’s necessary to modify the ajax function updateSuccess() ?

Also I was wondering if it’s possible to set a limit of notifications to display in the box, like the latest 5 notifications, or also it’s necessary to modify the notification_update() function in views.py to add a range in the line:

new_notifications = request.user.notifications.filter(id__gt=last_notification).active().prefetch()

or do that on jQuery scripts?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
quevon24commented, Jan 19, 2018

Thanks for you answers and the great work with this module. I also noticed that if there is no notification and your receipt one while you open the dropdown box(in: notifications/all ) adds the new notification but doesn’t remove the message: No notifications yet.

0reactions
DanailYordanovcommented, Dec 25, 2019

I also noticed that if there is no notification and your receipt one while you open the dropdown box(in: notifications/all ) adds the new notification but doesn’t remove the message: No notifications yet.

Yes, this should be fixed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Update notifications via Ajax - jquery - Stack Overflow
Let's say you have a div somewhere that contains that information. <div id="unreadNotification" > ...
Read more >
How to count number of notification on an icon?
Bootstrap provides us with badges to display counts on an icon which can be used to show unread notifications/messages etc.
Read more >
Creating Real Time Notification System in PHP and AJAX
In this article, I will show you how to create a simple notification system by using PHP and AJAX. I will also use...
Read more >
ASP.NET MVC - Using Ajax Helpers with Razor Partial Views
An empty HTML element is used as the target for the Ajax action that renders either the e-mail address or postal address partial...
Read more >
An Ajax page update mini-tutorial - Daniel Nouri
Well, when we update our <div id="message"> through Ajax, the notifications pop-up won't display. This is because the document ready handler ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found