notification-bundle
notification-bundle copied to clipboard
make notification as seen on clik on it
Hi i'm getting the notification by this code
{% for item in notificationList %}
<li class="media notification-message">
<a href="{# path('mark_notifcation_as_seen',{'notification':item.notification.id}) #}">
<div class="media-body">
<p class="m-0 noti-details">{{item.notification.message}}</p>
<p class="m-0"><span class="notification-time">{{item.notification.date|date }}</span></p>
</div>
</a>
</li>
{% endfor %}
so what i need is when the current user click on one of this notification that notification has to mark as read and redirect user to another view
what should i do
HTML
<a href="#" id="markAsRead{{ loop.index }}">markAsRead</a>
JS
$('#markAsRead{{ loop.index }}').click(function(){
$.post('{{ mgilet_notification_generate_path('notification_mark_as_seen', item.notifiableEntity, item.notification) }}', function() {
location.reload();
});
});
Hope it helps.
How do you expect to read the variable item
in javascript? This would be available only in the for loop right?
Yes.
@beamop So, what's the other way around?