0

I already found a similar post here:

register-javascript-for-document-library

But instead of adding a content/script editor to every document library, as suggested, I'd prefer to add my code to the system master page and have it triggered only when a document library gets opened. Does any one have a solution for this? The code I developed is working great when I put it in a script editor, now how can I make it run from the master page only on document libraries?

0

you maybe get Doc. library by checking the url if it contains Forms/AllItems.aspx and then execute your code

  • Thanks for the reply. With your solution though I cannot create custom views for libraries... What if, for instance, I switch from AllItems.aspx to Custom.aspx? – supertrip86 Apr 10 '18 at 13:16
0

Ok, I solved my problem. Here's my solution:

        if ( ctx != null && ctx.listBaseType == 1) {
            //YOUR CODE HERE
        }

This way the code will be executed only if the Sharepoint ctx variable is loaded and the library you open is a Document Library (that means that listBaseType == 1).

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.