jQuery not working on 2nd page of SharePoint list

On our SharePoint list, we have anchor tags opening in a new window via:

<script type="text/javascript" src="/SiteAssets/jquery-latest.min.js"></script>

    <script type="text/javascript">
    $(function() {
        var $t = $("table.ms-listviewtable>tbody tr td:nth-child(4) a");

        var interval = setInterval(function() {
            $t.each(function(){
              $(this).attr("target", "_blank");
            });
        }, 1000);
    });
</script>

When you hit page 2 in the list, the anchor tags open in the same window, and via "Inspect Element" do not contain the "target="_blank" like on the first page.

The jQuery code above is in a CEWP which points to a .txt file containing the code via CEWP property of "Content Link :: To link to a text file, type a URL."

I can't figure out why 2nd page is causing this issue. If I go back to 1st page, from 2nd page, the jQuery doesn't work either. In the query string, the URL has appended "?PageView=Shared&InitialTabId=Ribbon.WebPartPage&VisibilityContext=WSSWebPartPage#I"

If I take this string noted above off the end of the URL, and the view name is the last thing in the URL (viewname.aspx), the jQuery works on page 1.

With Minimal Download Strategy feature turned on or off, no difference in fixing issue.
  • Edited by bubberz1 10 hours 22 minutes ago more info for post
April 17th, 2015 3:56pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics