Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

JSLink to Modify URL to open in new Window

$
0
0

I'm trying to write a javascript to open a URL in a new window. I'm not the best at javascript and can't seem to get the URL formatted correctly.  Here is my example:

(function () {

//   Initialize the variables for overrides objects
	var overrideCtx = {};
	overrideCtx.Templates = {};

//	alert("Override call worked");

//  Use BaseViewID and ListTemplateType to narrow focus/scope on
//	which web parts on the page are affected
//	overrideCtx.BaseViewID = 1;
//	overrideCtx.ListTemplateType = 100;

    /*
     * Using the Fields override leaves the rest of the rendering intact, but
     * allows control over one or more specific fields in the existing view
     */
	overrideCtx.Templates.Fields = {
		//'LinkLocation': { 'View' : 'Animal' }
		//'LinkLocation': { 'View' : '<b><#=ctx.CurrentItem.LinkLocation#></b>'}

		//'LinkLocation': { 'View' : '<a href=ctx.CurrentItem.LinkLocation><#=ctx.CurrentItem.LinkLocation#></a>'}
		'LinkLocation': { 'View' : '<div><a href=""ctx.CurrentItem.LinkLocation""><#=ctx.CurrentItem.LinkLocation#></a><div>'}

	};

    /*
     * Register the template overrides.
     */
	SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();

I'm not sure how to put the quotations around the hyperlink.  When I do get it sort of working it puts "ctx.CurrentItem.LinkLocation" in as the path along with the local hostname. 

Can someone tell me what I'm doing wrong?


David Jenkins


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>