notification-bundle icon indicating copy to clipboard operation
notification-bundle copied to clipboard

make notification as seen on clik on it

Open rakini-yassine opened this issue 5 years ago • 4 comments

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

rakini-yassine avatar May 08 '19 15:05 rakini-yassine

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.

beamop avatar May 08 '19 16:05 beamop

How do you expect to read the variable item in javascript? This would be available only in the for loop right?

aquibbaig avatar Jun 08 '19 08:06 aquibbaig

Yes.

beamop avatar Jun 08 '19 08:06 beamop

@beamop So, what's the other way around?

aquibbaig avatar Jun 08 '19 08:06 aquibbaig