Stump the Panel Topic: jQuery - Open link in new window for view using Groupings http://www.endusersharepoint.com/STP/ Paul Grenier, Lead Moderator en Wed, 08 Apr 2009 09:27:53 +0000 AutoSponge on "jQuery - Open link in new window for view using Groupings" http://www.endusersharepoint.com/STP/topic/jquery-open-link-in-new-window-for-view-using-groupings#post-5740 Tue, 07 Apr 2009 16:48:53 +0000 AutoSponge 5740@http://www.endusersharepoint.com/STP/ <p>I discuss some techniques for doing this in a pair of articles:<br /> <a href="http://www.endusersharepoint.com/?p=1489" rel="nofollow">http://www.endusersharepoint.com/?p=1489</a></p> <p>and another coming out on the 9th. </p> Christophe on "jQuery - Open link in new window for view using Groupings" http://www.endusersharepoint.com/STP/topic/jquery-open-link-in-new-window-for-view-using-groupings#post-5697 Sat, 04 Apr 2009 01:44:48 +0000 Christophe 5697@http://www.endusersharepoint.com/STP/ <p>@kayjay: it's not a conflict issue. It's just that in a collapsed view, SharePoint only calls items on demand (let's call this a "best practice"). When you run your script, the items are not in the page yet, so the formatting doesn't apply to them.<br /> As Paul suggests, you need to re-run your function everytime you expand the group. </p> AutoSponge on "jQuery - Open link in new window for view using Groupings" http://www.endusersharepoint.com/STP/topic/jquery-open-link-in-new-window-for-view-using-groupings#post-5681 Fri, 03 Apr 2009 16:02:23 +0000 AutoSponge 5681@http://www.endusersharepoint.com/STP/ <p>I have written some articles that will help with this. One should come out in a day or two that uses AOP. However, the brute force method is to rewrite the SharePoint function that renders the new HTML from an expanded group like this:</p> <p>'function ExpGroupRenderData(htmlToRender, groupName, isLoaded) {<br /> $("#tbod"+groupName+"_").attr("isloaded",isLoaded)<br /> .html(htmlToRender)<br /> .show("fast",___callback___);'</p> <p>where callback is a call to your custom function. </p> <p>If you look at some of my code examples, I use that to call something like initPreview(group) so I can pass the groupName from ExpGroupRenderData into my function.</p> <p>'function initPreview(group){<br /> if (!group){group = "#MSO_ContentTable";}<br /> $(group+" a[href*='DispForm.aspx']").bindPreview();<br /> ...<br /> '</p> <p>When I run the init function, I don't put a group, and it defaults to the main content area. When the new version of the SP function runs it:</p> <p>'.show("fast",initPreview("#tbod"+groupName+"_"));'</p> <p>I pass the group so I can select the group by ID.</p> <p>I hope that helps. Like I said, if you're still stuck, my new AOP article should make it as simple as this can get. </p> kayjay on "jQuery - Open link in new window for view using Groupings" http://www.endusersharepoint.com/STP/topic/jquery-open-link-in-new-window-for-view-using-groupings#post-5295 Fri, 20 Mar 2009 07:32:00 +0000 kayjay 5295@http://www.endusersharepoint.com/STP/ <p>Hi,</p> <p>The SharePoint "Link to a Document" content type allows you to easily add links into document libraries. The HTML code for a "Link to a Document" looks like this:</p> <p><code>&lt;a href=&quot;/sites/Nest/V3Training/Onboarding.aspx&quot;&gt;Onboarding&lt;img width=&quot;1&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;Use SHIFT+ENTER to open the menu (new window).&quot; class=&quot;ms-hidden&quot; src=&quot;/_layouts/images/blank.gif&quot;/&gt;&lt;/a&gt;</code></p> <p>I have been using the jQuery code below to open these links into a new window.<br /> The code works fine on library views that DO NOT use the <strong>grouping</strong> feature. It also works fine for views with grouping that initially display ALL Groups EXPANDED.</p> <p>However, it <strong>refuses to work when the library view uses grouping and ALL Groups are COLLAPSED</strong>.<br /> The grouping feature in SharePoint uses Javascript functions and I guess it conflicts with the jQuery code somehow. I just can't figure out how!</p> <p><strong>Any ideas? Thanks!</strong></p> <pre><code>&lt;script src=&quot;http://mysp/sites/Nest/JQuery/jquery.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt; $(document).ready(function() { $(&#39;a[onclick*=SharePoint.Link]&#39;).attr(&#39;target&#39;,&#39;_blank&#39;); var test = $(&#39;a[onclick*=SharePoint.Link]&#39;); alert(test); }); &lt;/script&gt;</code></pre>