georapbox / ReadMore.js

JavaScript library that adds a 'read more' functionality on the text blocks that is applied to.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Click event sometimes reloads page

owlvark opened this issue · comments

This nice, compact plugin does exactly what I needed. However, I recently had an issue where when the "read more" link was clicked, the whole page reloaded.

I have not tracked down the exact cause of this and why it only happens in certain circumstances.

What I did manage to do is stop it from happening by adding preventDefault to the click handler so the browser doesn't "follow the link" and reload.

If you are interested in adding this fix, let me know and I will make a PR.

Hi @owlvark ,

The issue could probably be because somehow an href attribute is added to the "read more" link.
Nevertheless, your suggestion about adding preventDefault() in order to guard against such scenarios is correct, so I made the fix under this PR. Please let me know if you come across any more issues with this one. Thanks!

Hi @georapbox ,

I have tested the latest release (v1.2.0) and I can confirm that your referenced PR fixes this issue.

Thanks for the quick response!