Random quote generator review - tweet quote not updating

Random quote generator review - tweet quote not updating
0

#1
                $("#quote_show").html("\"" + response.quoteText + "\"");
                $("#author").html(response.quoteAuthor);
                $("#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?


#2

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


#3

THANKS! That fixed my problem.