Functions

Social Sharing

Functions in the Social Sharing category interact with the solution after it’s been launched and the function janrainSocialOnLoad has been called.

addWidgetTo

The addWidgetTo function attaches the share tool to an HTML element. This allows the share widget to be dynamically added to a page.

The following fields in the janrain.social.addWidgetTo object interact with the social sharing solution:

Field Description
element The HTML element to attach to.
options An optional JavaScript object containing settings to use instead of the data-janrain-* HTML attributes. The keys are camelCase instead of harpoon-case, like in the HTML attributes, and do not include the data-janrain- prefix. For example, the setting
data-janrain-url="http://www.example.com"

becomes

url:"http://www.example.com".

Examples:

var e = document.createElement("div");
document.body.appendChild(e);
janrain.social.addWidgetTo(e, { url: "http://twitter.com", formFactor: "drawer" });

Using JQuery without options:

var placeholder = $("
<div></div>
")
    .attr("data-janrain-url", "http://bing.com")
    .appendTo(document.body);
janrain.social.addWidgetTo(placeholder[0])

If you wish to load the markup for Social Sharing after the page has loaded, you could manually instantiate a share bar on an element by targeting an element and using addWidgetTo. The following example would grab the last janrainSocialPlacholder element on the page and instantiate the tool there:

janrain.social.addWidgetTo($(".janrainSocialPlaceholder").get(-1), { url: "http://bing.com" })