Quote wont copy to tweet

Quote wont copy to tweet
0

#1

Heya, so here’s my codepen for the project, and I have managed to get everything else working. I can’t figure out why my quote wont post into my tweet when it’s opened on another page. I even looked up a couple of examples of other peoples solutions, and I seem to be running along the same lines as them. Someone mind lending a hand?


#2

@MarvinMerlin Your variable “quote” has local scope in the #execute onClick event.So, when you try to use “qoute” in the #twitter onClick event, it’s unreachable.


#3

Okay, so what should I do about that? I dont want to put the tweet event in the new quote click event, because then the button wont work.


#4

Would it be enough if I pulled the quote variable out of the jquery, have it quote=(""); and then inside the event make it so that quoteBank[randomNumber] = quote("") ?


#5

You can try this.

Declare your quote variable after the document ready, something like this…

$(document).ready(function() {

var quote = "";

// new quote
$("#execute").on(“click”, function(){
quote = “”;
});
});


#6

Sweet baby jeebus it worked. Thanks @jamesperrin


#7

No problem, glad I could help. With a lot of things, a fresh pair eyes always helps.


#8

Totally, and thanks for the fast response. I had actually given up on this part of the project and moved on to the next one because the chat was so busy no one could take a second to look at my code.