Quote Machine Tweeting Oddly

Quote Machine Tweeting Oddly



My quote machine is tweeting oddly. On Firefox it opens a tweet page for every quote that has ever shown (FF version might be a year or two old), on Chrome, it opens a tweet page for only the first quote, so if you click ‘get quote now’ 5 times, for example, it will still tweet the first quote raised.

Can anyone kindly point me in the right direction.



While I’m not sure why exactly the error occurs, I have managed to fix it, at least on Chrome. I suspect putting everything inside the document.ready() function might be the reason? Either way, put the variables outside the functions, i.e., in the global scope and declare them as null. Then put the tweet button’s jQuery event outside as well.

So it looks something like:

var quotetext=null;
var quoteauthor=null;
<assign quotetext, quoteauthor>

$('#twitter').click(function() {
      window.open("https://twitter.com/intent/tweet?text=" + '"' 
      + quotetext + '" - ' +  quoteauthor);

Hope this helps!