melting_dog Posted May 27, 2012 Share Posted May 27, 2012 Hi all, I have been experimenting with a JQuery Twitter Plugin. In it, is has this line: //place the tweet within a paragraph tag within the main div. holder.append("<p>"+item.text.makeLinks()+"</p>"); Now, that makes sense: It simply puts the Tweet in paragraph tags and appends it to the holder. But I am unsure of what makeLinks() does. In fact it causes an error: Uncaught TypeError: Object Tweet text blah blah blah http://t.co/W6GNA4ps has no method 'makeLinks' If I remove the makeLinks() it runs fine but any links in the tweet to it do not work. Heres the full code: (function($){ //Creating Function called Twitterize $.fn.twitterize = function(username,options){ //check to see if the username has been set. if (username){ //create an object full of default settings. var defaultSettings = { count:'1' } // Finds which default settings have been overwritten by the options object // and creates a new object with all the new and untouched settings. var settings = $.extend(defaultSettings, options); // The URL for the Twitter JSON API. var url = "http://twitter.com/status/user_timeline/"+username+".json?count="+settings.count+"&callback=?"; //Variable to get around scope problem in callback function. var holder = this; //Contact Twitter $.getJSON(url, //This function is called when twitter responds with the appropriate information. function(data){ //Step through each tweet. $.each(data, function(i, item) { //place the tweet within a paragraph tag within the main div. holder.append("<p>"+item.text.makeLinks()+"</p>"); }); }); } else{ //Username paramater has not been set. console.debug("jquery plugin twitterize requires a username! Check your parameters"); } //Return itself return this; };//END TWITTERIZE })(jQuery); Any help would be appreciate! Quote Link to comment Share on other sites More sharing options...
Oreo Posted May 27, 2012 Share Posted May 27, 2012 makeLinks is not a standard JavaScript function, you cannot pass functions through JSON so it's not coming from Twitter, and there is no attempt to bind item.text.makeLinks to a function in that code. The only way I could possible see this working is if the plugin author had bound makeLinks to the string prototype, but that's not done in the code either. The plugin is either incomplete or has a dependency on some external library that you don't have. You might want to check to see if the plugin author has a working demonstration of this script, as it would show you where makeLinks is defined. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.