1

I am very new to SharePoint and have written some code,in content editor web part, that interacted with lists and used some libraries that are available online like jQuery etc., my question is how do I use libraries that require a local installation (i.e can't just reference them using a link)?

2

As per your description, you should use the JSOM model, not the CSOM model.

Check the difference at CSOM vs JSOM vs SSOM vs REST


To use JSOM

You should first reference to the JavaScript object model:

  • References the AJAX library from the Microsoft Content Delivery Network (CDN).
  • References the jQuery library from the Microsoft CDN.
  • Extracts the host web URL from the query string.
  • Loads the SP.Runtime.js and SP.js files by using the getScript function in - - jQuery. After loading the files, your program has access to the JavaScript object model for SharePoint.
  • Continues the flow in the execOperation function.

Ex:

<script 
    src="//ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js" 
    type="text/javascript">
</script>
<script
    type="text/javascript"
    src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js">
</script>
<script type="text/javascript">
    var hostweburl;

    // Load the required SharePoint libraries.
    $(document).ready(function () {

        // Get the URI decoded URLs.
        hostweburl =
            decodeURIComponent(
                getQueryStringParameter("SPHostUrl")
        );

        // The js files are in a URL in the form:
        // web_url/_layouts/15/resource_file
        var scriptbase = hostweburl + "/_layouts/15/";

        // Load the js files and continue to
        // the execOperation function.
        $.getScript(scriptbase + "SP.Runtime.js",
            function () {
                $.getScript(scriptbase + "SP.js", execOperation);
            }
        );
    });

    // Function to execute basic operations.
    function execOperation() {

        // Continue your program flow here.

    }

    // Function to retrieve a query string value.
    // For production purposes you may want to use
    // a library to handle the query string.
    function getQueryStringParameter(paramToRetrieve) {
        var params =
            document.URL.split("?")[1].split("&amp;");
        var strParams = "";
        for (var i = 0; i < params.length; i = i + 1) {
            var singleParam = params[i].split("=");
            if (singleParam[0] == paramToRetrieve)
                return singleParam[1];
        }
    }
</script>

Learn about JSOM in SharePoint at Complete basic operations using JavaScript library code in SharePoint


To use CSOM

You should copy the below references from a Sharepoint Server to your Dev server (PC) then add them to your solution

  • Microsoft.SharePoint.Client.dll
  • Microsoft.SharePoint.Client.Runtime.dll

These assemblies can be found in the 15 Hive folder: %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\15\ISAPI.

Now you can get started to learn about CSOM in SharePoint at Complete basic operations using SharePoint client library code

0

you can: 1. add some libraries directly into your master page (to permanently have them in all the pages in your site) 2. put them in a page layout 3. put them in a library and add a tag to a content editor.

in any case, I would recommend using SpPlus js it's a great library and has great documentation. but in most cases, you are better to use RestApi(its easy and return json - csom & spPlus returns XML)

p.s is you are want to try using SpPlus Read the Quick start! - you need to add polyfill for ie11 (very easy).

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.