Last active
December 18, 2015 01:08
Code samples showing how to add Twitter button into a Meteor application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template name='welcomePage'> | |
<a href="https://twitter.com/intent/tweet?screen_name=TemplHub" | |
class="twitter-mention-button" | |
data-related="TemplHub"> | |
Tweet to @TemplHub | |
</a> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Template.welcomePage.rendered = function () { | |
addTwitterWidget(); | |
} | |
function addTwitterWidget() { | |
!function (d, s, id) { | |
var js, fjs = d.getElementsByTagName(s)[0], | |
p = /^http:/.test(d.location) ? 'http' : 'https'; | |
if (!d.getElementById(id)) { | |
js = d.createElement(s); | |
js.id = id; | |
js.src = p + '://platform.twitter.com/widgets.js'; | |
fjs.parentNode.insertBefore(js, fjs); | |
} | |
}(document, 'script', 'twitter-wjs'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment