JavaScript stopped working after applying “group by” in list view

Omar Tabasi 21 Reputation points
2021-07-08T15:31:05.423+00:00

Hi Everyone,

I have a script to open links in a new window that works fine on all document library views except on the view that has a group by, not sure what I need to do to make it work, this is SharePoint 2013 the script below:

<script src="https://code.jquery.com/jquery-1.11.2.min.js" type="text/javascript"></script><script type="text/javascript">
    $(document).ready(function () {

            $(".ms-listviewtable tr td a").attr("target", "_blank");

    });
</script>

Thanks.

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,969 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,609 questions
0 comments No comments
{count} votes

Accepted answer
  1. MichaelHan-MSFT 18,031 Reputation points
    2021-07-09T02:46:44.693+00:00

    Hi @Omar Tabasi ,

    In list view applying "group by", the html of the link is hidden and not loaded. As a workaround, you could change your js code to the below in the group by view:

     $(document).ready(function () {  
             
             setInterval(function(){$(".ms-listviewtable tr td a").attr("target", "_blank");},1000);  
             
     });  
    

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.