none
using the people picker in the front-end of SharePoint 2013 and load javscript files RRS feed

  • Question

  • Hello together,

    I'm trying to use the people picker function in the front-end of SharePoint 2013 and I'm now stuck with the answer how can I load all the needed Javascript files in the front-end. I'm not able to use server-side code.

    I tried to register the files, but I got an error message. This is my code so far:

    $(document).ready(function (){
            
            SP.SOD.registerSod('sp.taxonomy.js', SP.Utilities.Utility.getLayoutsPageUrl('sp.taxonomy.js'));
            SP.SOD.registerSod('clientforms.js', SP.Utilities.Utility.getLayoutsPageUrl('clientforms.js'));
            SP.SOD.registerSod('autofill.js', SP.Utilities.Utility.getLayoutsPageUrl('autofill.js'));
            SP.SOD.registerSod('clienttemplates.js', SP.Utilities.Utility.getLayoutsPageUrl('clienttemplates.js'));
            SP.SOD.registerSod('clientpeoplepicker.js', SP.Utilities.Utility.getLayoutsPageUrl('clientpeoplepicker.js'));
              
             SP.SOD.LoadMultiple(['sp.taxonomy.js','clienttemplates.js','clientforms.js','clientpeoplepicker.js','autofill.js'],customCode);

            
        
        });
        
        function customCode(){
        
        alert("hallo");
        }

    but this is not working.

    Best regards and thanks

    Matthias

    Thursday, January 4, 2018 10:26 AM

All replies

  • Hello Matthias

    Did you load all javascript files like below Please let me know

    <script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script> <script type="text/javascript" src="/_layouts/15/sp.taxonomy.js"></script> <script type="text/javascript">


    Thursday, January 4, 2018 12:37 PM
  • Hi Matthias,

    You can load JS file via adding HTML tag directly as below:

        <script type="text/javascript" src="/_layouts/15/sp.taxonomy.js"></script>
        <script type="text/javascript" src="/_layouts/15/clientforms.js"></script>
        <script type="text/javascript" src="/_layouts/15/autofill.js"></script>
        <script type="text/javascript" src="/_layouts/15/clienttemplates.js"></script>
        <script type="text/javascript" src="/_layouts/15/clientpeoplepicker.js"></script>

    You can also use jQuery to load JS file dynamically:

        <script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.3.min.js"></script>
        <script type="text/javascript">
            $.getScript("/_layouts/15/sp.taxonomy.js").done(function () {
                //load successfully, do something
            }).fail(function () {
                //load failed, do something
            });
            $.getScript("/_layouts/15/clientforms.js");
            $.getScript("/_layouts/15/autofill.js");
            $.getScript("/_layouts/15/clienttemplates.js");
            $.getScript("/_layouts/15/clientpeoplepicker.js");
    
        </script>


    Best regards,

    Lee Liu


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com



    Friday, January 5, 2018 3:17 AM
  • Hi,

    I am checking to see how things are going there on this issue.

    Best regards,

    Lee Liu


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, January 8, 2018 1:30 AM