需要帮助twitter小部件

Cat*_*ish 3 html javascript css twitter jquery

我创建了一个jquery插件,在左边放置一个侧边栏用于社交媒体内容.我有下面的变量,这是内容的来源.我正在尝试使用小部件提取Twitter提要,但我不断收到错误"TWTR未定义".任何想法如何解决这一问题?

这个页面正在调用我创建的插件http://social.allthingswebdesign.com

var content = (
            '<div class="contentArea visible" id="fb">FB Content Area</div>'+
            '<div class="contentArea" id="twit"><script src="http://widgets.twimg.com/j/2/widget.js"></script><script>new TWTR.Widget({version: 2,type: \'profile\',rpp: 4,interval: 6000,width: 250,height: 280,theme: {shell: {background: \'#333333\',color: \'#ffffff\'},tweets: {background: \'#ffffff\',color: \'#444444\',links: \'#e02046\'}},features: {scrollbar: false,loop: false,live: false,hashtags: true,timestamp: true,avatars: false,behavior: \'all\'}}).render().setUser(\'CSuitesIndepend\').start();</script></div>'+
            '<div class="contentArea" id="youtube">Youtube Video</div>'+
            '<div class="contentArea" id="yelp">Yelp reviews</div>'+
            '<div class="contentArea" id="ta">Trip Advisor Advice</div>'+
            '<div class="contentArea" id="li">The Linked In Page</div>'
        );
Run Code Online (Sandbox Code Playgroud)

另外 - 如果我<script src="http://widgets.twimg.com/j/2/widget.js"></script>从插件中删除这一行,并将其放在我的网页的头部,我所看到的就是twitter feed.

编辑:好的,现在我在想,为什么我不能只将twitter小部件代码附加<script> new TWTR.Widget({ version: 2, type: 'profile', rpp: 4, interval: 6000, width: 250, height: 280, theme: { shell: { background: '#333333', color: '#ffffff' }, tweets: { background: '#ffffff', color: '#444444', links: '#e02046' } }, features: { scrollbar: false, loop: false, live: false, hashtags: true, timestamp: true, avatars: false, behavior: 'all' } }).render().setUser('CSuitesIndepend').start(); </script>到通过插件动态插入的元素?

当我尝试这段代码时,它不会在#tweetFeed中插入任何内容 -

$(document).ready(function() {

        // add the sidebar plugin
        $('html').social(function() {
            //console.log('#tweetFeed = '+ $('#tweetFeed').parent().html());
            $('#tweetFeed').insertAfter("<p>TEST</p>");
        }); 

        //console.log('#tweetFeed = '+ $('#tweetFeed').parent().html());
        $('#tweetFeed').insertAfter("<p>TEST</p>");
    });
Run Code Online (Sandbox Code Playgroud)

小智 5

有一个未记录的功能,允许您定位要加载窗口小部件的元素的ID.我能够使用$ .getScript以及twitter提供的常规窗口小部件代码来加载它来代替选择.

这是我使用的脚本,我希望这有助于......


    $(document).ready(function(){
    $.getScript('http://widgets.twimg.com/j/2/widget.js', function () {
    new TWTR.Widget({
    version: 2,
    type: 'profile',
    id : 'twitterBox',
    rpp: 4,
    interval: 30000,
    width: 'auto',
    height: 'auto',
    theme: {
    shell: {
        background: 'transparent', //this is important
        color: '#333'
    },
    tweets: {
      background: 'transparent', //this is important
          color: '#666',
      links: '#d14836'
    }
    },
    features: {
    scrollbar: false,
    loop: false,
    live: false,
    behavior: 'all'
    }
    }).render().setUser('username').start();
    });

    });