Why write custom web parts or XSLT when you have JQuery?
May 16. 2010 0 Comments
- Posted in:
- SharePoint 2010
As I have started migrating my old web sites over to SharePoint 2010 I have been evaluating customizations that I made for my MOSS 2007 sites. On many occasions I had used the dataview web part to do thing like opening external links in new windows and hiding headers that are not needed. In comes JQuery and the content viewer web part.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ //Hide the header row $(".ms-listviewtable tbody tr:nth-child(1)").hide(); //Open links in new window​ $(".ms-listviewtable tbody a").click(function(){ this.target = "_blank"; }); }); </script>
This was pretty easy because all the list view web parts on the page contains all external links but this could be pretty easily to check the links before opening them in an external window.