0

I am trying to get the script found under 'Enforce Drag and Drop documents to apply metadata' to work and I am always getting an 'Undefined' error here:

$.getScript("path_to_my_custom_js_file/DragDrop.Extended.js");

I have tried several different locations and ways to write the URL but it always comes back with the same error. Any help will be appreciated, thanks.

  • Is .js file located in _layouts folder. – Nadeem Yousuf Feb 2 '15 at 13:10
0

Suppose .js file is located in a folder in _layouts folder, then use following code to load the file:

var url = _spPageContextInfo.siteAbsoluteUrl + '/_layouts/15/FolderName/DragDrop.Extended.js
$.getScript(url);

Suppose the file is located in a folder in dcoument library in root site collection named. Then this code can be used:

var url = _spPageContextInfo.siteAbsoluteUrl + '/LibraryUrl/Folder/DragDrop.Extended.js'
$.getScript(url);

UPDATE

If the library is in sub site and the page where you are running the script is also in that same subsite, then you can use:

var url = _spPageContextInfo.weAbsoluteUrl + '/LibraryUrl/Folder/DragDrop.Extended.js'
    $.getScript(url);
  • The .js file is located in the document library. I tried your suggestion but it still gives me the undefined error. – Allan Syvret Feb 2 '15 at 14:58
  • Can you paste some code in the question. Also, is the document library in a root site collection or in a subsite? – Nadeem Yousuf Feb 2 '15 at 15:03
  • Here is the part of the code that is giving me issues, along with the start of the script: <script src="ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type="text/javascript"></script> <script src="ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.js" type="text/javascript"></script><script unselectable="on"> var url = _spPageContextInfo.siteAbsoluteUrl + '/Document%20Library/Uploads/DragDrop.Extended.js'; window.onload = function(){ setTimeout( function(){ if(typeof UploadProgressFunc != "undefined"){ $.getScript(url); } }, 4000); }; – Allan Syvret Feb 2 '15 at 15:06
  • The Document Library is in a subsite. – Allan Syvret Feb 2 '15 at 15:08
  • And where is the page that is using this script. Is it also in the subsite? – Nadeem Yousuf Feb 2 '15 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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