I read this topic read more toggle on stackoverflow Rails truncate with a 'read more' toggle. How can I add a return to truncate or return to its original form or text in the code below without having to refresh the page?
<div>
<% if @major.glance.length > 250 %>
<%= truncate(@major.glance, length: 250) %>
<%= link_to '...Read more', '', class: "read-more-#{@major.id}" %>
<script>
$('.read-more-<%= @major.id %>').on('click', function(e) {
e.preventDefault()
$(this).parent().html('<%= escape_javascript @major.glance %>')
})
</script>
<% else %>
<%= @major.glance %>
<% end %>
<div>