BuddyDev

Search

reload current page

  • Participant
    Level: Enlightened
    Posts: 36
    rav on #25625

    Hi,
    I use the BP Notification Widget plugin and I am very happy with this solution. However, I have a question. I would like the page to open in a new window after clicking the notification, which is a link, and the current notification page to be reloaded. In the notification I already have target=”_blanc” but how to reload the current page?

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #25628

    Hi Rav,
    Thank you for the topic.

    Since this is not a common request, May I suggest using javascript to add the target attribute on page load? That will serve your purpose.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 36
    rav on #25636

    Hi Brajesh,
    Thank for your response.
    I’m not sure how to do it with javascript. I added to the link
    onClick = “window.location.reload (true)”

    The page is reloading, however, I need two reloads to load properly. The first reload adds nothing and after reloading the link I clicked should disappear.

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #25678

    Please remove your changes.

    After that, Please put it in any of your javascript file.

    
    (function ($) {
        $(document).ready(function () {
            // setup target attribute.
            $('.bp-notification-list a').each(function () {
                var $this = $(this);
                $this.attr('target', '_blank');
            });
    
            $(document).on('click', '.bp-notification-list a', function () {
                setTimeout(function () {
                    window.location.reload();
                }, 100);
            });
        });
    
    })(jQuery);
    
    

    It will open the notification target in new tab and reload current page.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved