I'm rendering a link with react:
render: -> `<a className="upvotes" onClick={this.upvote}>upvote</a>` Then, above I have the upvote function:
upvote: -> // do stuff (ajax) Before link I had span in that place but I need to switch to link and here's the trouble - every time I click on .upvotes the page gets refreshed, what I've tried so far:
event.preventDefault() - not working.
upvote: (e) -> e.preventDefault() // do stuff (ajax) event.stopPropagation() - not working.
upvote: (e) -> e.stopPropagation() // do stuff (ajax) return false - not working.
upvote: (e) -> // do stuff (ajax) return false I've also tried all of the above using jQuery in my index.html, but nothing seems to work. What should I do here and what I'm doing wrong? I've checked event.type and it's click so I guess I should be able to avoid redirect somehow?
Excuse me, I'm a rookie when it comes to React.
Thank you!
upvote? This might be a context issue.preventDefault