grails (11) vaadin (11) meteor (6) java (4) elasticsearch (3) apple (2) centos (1) cloudbees (1) google analytics (1) gradle (1) heroku (1) javafx (1) javascript (1) jdbc (1) jug (1) logback (1) logging (1) mac os (1) management (1) mongodb (1) mongolab (1) mysql (1) twitter (1) ubuntu (1)

Monday, June 3, 2013

Twitter buttons in Meteor

The following steps show how to add Twitter button into a Meteor application.
  1. Add the link which represents Twitter button into the template:
  2. <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>
  3. Place the JavaScript provided by Twitter to the .js file for the template:
  4. 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');
    }
    view raw welcomePage.js hosted with ❤ by GitHub
I took this code from http://templhub.com application.

No comments:

Post a Comment