question

OmarTabasi-8000 avatar image
0 Votes"
OmarTabasi-8000 asked MichaelHan-MSFT edited

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

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-devoffice-sharepoint-server-development
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

MichaelHan-MSFT avatar image
0 Votes"
MichaelHan-MSFT answered

Hi @OmarTabasi-8000,

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.