Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Client Side Taxonomy Picker For SharePoint

$
0
0

Hello Folks,

On Premise SharePoint 2013, Implementing a Client Side Taxonomy Picker For SharePoint using below blogs:

https://www.c-sharpcorner.com/UploadFile/93cb27/client-side-taxonomy-picker-for-sharepoint-app/ 

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

Added the code using a Script Editor, and the control shows only on Edit Mode - when I save the page, the control disappears and throws the following error "b.get_path is not a function

Tried many combinations however it looks like a bug as the same code works fine in 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> 


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>