Средство выбора таксономии на стороне клиента для SharePoint - PullRequest
0 голосов
/ 28 августа 2018

В Premise SharePoint 2013, реализация средства выбора таксономии на стороне клиента для SharePoint с использованием следующих блогов:

https://www.c -sharpcorner.com / UploadFile / 93cb27 / клиент-сборщик таксономии на стороне клиента для приложения /

https://blogs.msdn.microsoft.com/richard_dizeregas_blog/2014/03/13/taxonomy-picker-in-sharepoint-provider-hosted-app/

Добавлен код с использованием редактора сценариев, и элемент управления отображается только в режиме редактирования. Когда я сохраняю страницу, элемент управления исчезает и выдает следующую ошибку «b.get_path не является функцией»

Перепробовал много комбинаций, однако это выглядит как ошибка, поскольку тот же код отлично работает в SharePoint Online.

<link href="https://server/sites/TeamSite/SiteAssets/CodeLibrary/styles/taxonomypickercontrol.css" rel="stylesheet"/>
<script type="text/ecmascript" src="https://server/sites/TeamSite/SiteAssets/CodeLibrary/jquery-1.9.1.js"></script>
<script type="text/ecmascript" src="https://server/sites/TeamSite/SiteAssets/CodeLibrary/taxonomypickercontrol.js"></script>
<script type = "text/javascript"  src = "https://server/sites/TeamSite/SiteAssets/CodeLibrary/taxonomypickercontrol_resources.en.js"></script>
<script type = "text/javascript"  src = "https://server/sites/TeamSite/_layouts/15/sp.core.js" ></script>   
<script type = "text/javascript"  src = "https://server/sites/TeamSite/_layouts/15/sp.runtime.js" ></script>   
<script type = "text/javascript"  src = "https://server/sites/TeamSite/_layouts/15/sp.taxonomy.js" ></script>   

<script type = "text/javascript">

if (myStronglyTypedObj === undefined) {
    var myStronglyTypedObj = {};
}

myStronglyTypedObj = {
    // Object Globals 
    "g": {},
    // Pre-initialization functions ensure scripts SharePoint dependencies are loaded
    "preinit": function() {
        // Load necessary libraries
        SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function() {
            // Register what you need from SharePoint (in this case the sp.runtime)             
            SP.SOD.registerSod('sp.runtime.js', SP.Utilities.Utility.getLayoutsPageUrl('sp.runtime.js'));                                               
            // Register what you need from SharePoint (in this case the term store)             
            SP.SOD.registerSod('sp.taxonomy.js', SP.Utilities.Utility.getLayoutsPageUrl('sp.taxonomy.js'));                                             
            // Load the registered items
            SP.SOD.executeFunc('sp.taxonomy.js', 'SP.Taxonomy.TaxonomySession', myStronglyTypedObj.init());
        });     
    },
    // The main Initialization function
    "init": function() {
        /* Check if SP.Taxonomy actually exists yet
         * PLEASE NOTE that it's common that these objects aren't available, even if you've properly loaded them in the "preinit" function. 
         * This bit of code checks if the object is available, and if it's not, waits for 200ms and then tries again until this object is loaded
         */
        if (SP.Taxonomy) {
            console.log("SP.Taxonomy ready... continuing scripts...");
            myStronglyTypedObj.therest();
        } else {
            console.log("SP.Taxonomy not ready...  set timeout and try again after 200ms");
            setTimeout(myStronglyTypedObj.init, 200);
        }
    },
    "therest": function() {
        // Continue with your code here...
        try {
            var context = new SP.ClientContext()
            $('#taxPickerKeywords').taxpicker({ isMulti: true, allowFillIn: true, termSetId: "63858201-dd9b-46b1-b1bb-b6a054fa7cb7" }, context);
        }
        catch(err) {
            alert(err.message);
        }       
    }
}

 $(document).ready(function(){
    myStronglyTypedObj.preinit();
 });
 </script>  

<div>  
  <input type="hidden" id="taxPickerKeywords" />  
</div> 

1 Ответ

0 голосов
/ 30 августа 2018

Как уже говорилось, он работает в SharePoint Online, хотя я проверил версию нашей фермы и похоже, что наш блок разработчика не обновился.

После исправления все заработало нормально.

Спасибо за вашу ценную помощь. enter image description here

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...