Social Sharing JavaScript API: Social Sharing Functions

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. 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 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">
 vare = 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">
 varplaceholder = $("<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>