Skip to content

Instantly share code, notes, and snippets.

@b20n
Created October 14, 2011 20:31
Show Gist options
  • Save b20n/1288249 to your computer and use it in GitHub Desktop.
Save b20n/1288249 to your computer and use it in GitHub Desktop.
Dynamically drawing superbars in arbitrary elements...
var drawShare = function (element, config) {
if (meteor && !meteor.missing(meteor.tracking.settings.cookie_name)) {
var bar_id = meteor.random_id(4);
config.node = document.createElement('div');
config.node.id = bar_id;
config.node.className = "meteor_share_" + config.id;
config.node.style.position = 'relative';
element.appendChild(config.node);
meteor.sharing.superbar.configure(
config, bar_id, function (json) {
meteor.sharing.superbar.reinit(json);
});
} else {
// Recurse until track() has been called
setTimeout(function() { drawShare(element, config); }, 500);
}
};
$(document).ready(function() {
drawShare(document.getElementById("qwer"), {"id": "foo"});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment