I have developed a custom jQuery plugin that displays a sidebar on the left for social media content. The variable below contains the source of the content. I am currently facing an issue while trying to integrate a Twitter feed using the widget, as it keeps showing the error "TWTR is not defined". Any suggestions on how to resolve this?
The plugin I created can be accessed on this page
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>'
);
Furthermore, if I remove the line
<script src="http://widgets.twimg.com/j/2/widget.js"></script>
from the plugin and place it in the head section of my webpage, only the Twitter feed appears.
EDIT: I was thinking why couldn't I simply append the Twitter widget code -
<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>
- to the dynamically inserted element via the plugin?
However, when attempting this code, nothing gets inserted into #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>");
});