Help with twitter button in Random Quote Machine

Help with twitter button in Random Quote Machine
0

#1

Hi everybody,

I am stuck in the random quote machine. The problem I am facing now is that every new quote generates a new twitter button without deleting the previous one. I don’t completely understand how this button is generated, how the data (text, hashtags) are edited dynamically so I really don’t know how to delete old button when new one is generated.

https://alaminos.github.io/random-quote-machine/

Any help is extremely appreciated. Thanks in advance.


#2

You could simply add container.innerHTML = ''; to the top of your tweetBtn function after your variables.


#3

You can also implement the Tweet button yourself reasonably easily. Here’s what I did for my project:

  • implement a button-styled link (with Bootstrap) with a Twitter icon from FontAwesome.
  • when you display the quote, you also update the button’s href.

On a side note I think on line 49 “aync” should be “async”.


#4

Thank you, that worked perfectly. Why didn-t I think about it? :slight_smile: Thanks


#5

Well spotted thank you, I would have passed one hour longer looking for a solution. Thanks


#6

I am curious about how you implemented it exactly. Is your project still online so I can have a look at it?


#7

I would definitely add more space padding between the 2 buttons. They are too close to each other and it makes it hard to click. But I :heart: the overall look an feel of the page.


#8

Well it still needs improvements but sure, you can have a look. Please ignore the test suite. I added it to check if the app was compatible with the beta and it’s not. I’m working on something else right now so that will wait.