Social sharing JavaScript API functions
The content on this page deals with a legacy feature of the Akamai Identity Cloud (in this case, social sharing). If you are currently an Identity Cloud customer and are using social sharing, that feature is still supported. However, if you’re new to the Identity Cloud, social sharing is no longer available.
The Social Sharing solution supports client-side functions that allow you to dynamically load the sharing widget to a page after it has been loaded. Use the janrain.social method after the janrainSocialOnLoad function has been called to attach the share tool to an HTML element.
.addWidgetTo(element, options)
This method will accept an element to options mapping. The element is required and refers to the HTML element to which the sharing widget should be attached. options is an optional JavaScript object containing settings that will override anything currently set on the element in the data-janrain-* attributes. See the Social sharing JavaScript API instance settings for a list of valid keys that may be used. Do not include the data-janrain-* prefix. Use camelCase.
Example using JavaScript to create a new element, with options:
<script type="text/javascript">
var e = document.createElement("div");
document.body.appendChild(e);
janrain.social.addWidgetTo(e,{url:"http://twitter.com",formFactor:"drawer"});
</script>
Example using JQuery to create a new element, without options:
<script type="text/javascript">
var placeholder = $("<div></div>")
.attr("data-janrain-url","http://bing.com")
.appendTo(document.body);
janrain.social.addWidgetTo(placeholder[0])
</script>
Example using JQuery to add the share widget to an existing element (the last janrainSocialPlacholder element on the page):
<script type="text/javascript">
janrain.social.addWidgetTo($(".janrainSocialPlaceholder").get(-1),{url:"http://bing.com"})
</script>
Updated almost 2 years ago