Hi, I’m working on the random quote machine project and I’ve almost completed it except for one issue when I go to tweet a quote a separate twitter window opens with every quote I’ve seen before during that particular session.
I’m generating my quotes from a forismatic api and when I view the console all the api JSON request objects from previous quotes are listed.
I’m guessing I need a delete or reset on each on click for a random quote so old ones do not open twitter windows but I can’t find anything from googling.
Okay, yeah, I totally see the issue here. I have played around with it for a bit, and haven’t been able to solve it either, yet! Sorry!
There is only one thing that makes sense to me, although I am sure someone else might know with more confidence what the issue is. I wonder if the event handler on your twitter button is bound to that first quote object that is created. Therefore, no matter how many times the quote object is refreshed to a new one, the tweet button is still holding reference to the text in that original object.
I do wonder if @janschreiber has something, with creating a variable outside the scope of that event handler so that you can pass the text of the quote in. I think this may be a closure or binding issue…
I had a similar (but different) issue with my quote machine as well. Instead of it keeping all of my quotes in the new tweet, it would run make tweets equal to the number of times I had gotten a quote, so it became an issue rather quickly.
Mine was resolved by creating global variables, and then using those to tweet the quote + author.
I’m trying something similar with this pen, but I’m not having the best luck ATM.