Random quote generator review - tweet quote not updating

                $("#quote_show").html("\"" + response.quoteText + "\"");
                $("#tweet").on("click", function(){
                  window.open("https://twitter.com/intent/tweet?hashtags=&text=" + response.quoteText + ' -' + response.quoteAuthor);

This is a snipet from my random quote generator, at the end of my ajax call, that’s causing me some difficulty ( https://codepen.io/bdfoz/pen/LeNeXq?editors=1010 ).

I’m getting a new random quote on each click (which is stored in response.quoteText and response.quoteAuthor. However. the tweet URL encoding is not updating whenever the click happens. I can click 5 or 6 times and get a new quote showing everytime, but the URL encoding for twitter uses the first quote that was generated. Why?

You need to take off the click event using the .off method before you can create the new event.

1 Like

THANKS! That fixed my problem.