0

I have created a custom list definition and detailed in many articles across the net I have specified my file in the JSLink property of the view. For some reason it is no longer working.

<JSLink Default="TRUE">/_layouts/15/myfile.js</JSLink>

Note: I have also tried ~layouts. But for some reason when I create the list it is no longer working. I have tried creating the list in both Powershell and the UI.

When I set the JSLink property on the web part on the view, it works as expected, but no through the schema.xml any more.

The javascript is trivial, basically just formatting a date not to show the time. Which is irrespective because the file isn't loaded. I've put a console.log("") message inside the file, which is only called when I set the JSLink property on the web part itself. I can also see from View Source that the file is not being added.

I have checked the JSLink property on the View in Powershell and it is set to the one I define in the schema.xml

Is there something I am missing?

1
  • Have you got a solution for this? I'm also getting the same issue. Could you please share if you have got it worked ?
    – Anish V
    Jan 10, 2014 at 10:15

3 Answers 3

6

If the javascript file is located directly in the folder you don't have to specify relative/full path as SharePoint will figure it out itself.

If you however have it located in a specific folder in either a document library or a in layouts, only then are you required to add a relative/full path to the javascript file.

Example: 

(Located in layouts)

<JSLink>MyCustomJSFile.js</JSLink>

(Located in a folder)

// Located in subfolder in Layouts
<JSLink>~layouts/MyJSFiles/MyCustomJSFile.js</JSLink>
// Located in subfolder in Style Library on root
<JSLink>~sitecollection/Style Library/MyJSFiles/MyCustomJSFile.js</JSLink>
// Located in subfolder in Assets
<JSLink>~site/SiteAssets/MyJSFiles/MyCustomJSFile.js</JSLink>

Example with multiple javascript files

(Located in layouts)

// OOB SharePoint uses this method as well
<JSLink>MyFirstCustomJSFile.js|MySecondCustomJSFile.js</JSLink>
1

Try to use one of the tokens

  • ~site
  • ~sitecollection
  • ~layouts
  • ~siteLayouts
  • ~siteCollectionLayouts

I faced with problem that JSLink does not work without them.

Edited

In some cases you should encode "~" symbol.

1
  • Thanks, yeah, as stated, I've tried the ~layouts token. No joy.
    – SteveCl
    Oct 16, 2013 at 8:48
0

try this, it works for me, as I deployed solution using Visual Studio,

 <JSLink Default="TRUE">../_layouts/15/myFeaturesFolder.Features/myJSLINKFILE.js</JSLink>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.