Hi there guys trying to gather some ideas to tackle this problem. i am using rails to truncate a name of a company that`s over 30 characters in length. the page will load the name of the company into the header of the page if the name is too long it will cut some other stuff off and messes with the styling. to truncate i have this server side.
truncate(company.title, :ommision => "...", :length => 20)
is it possible to maybe do something in jQuery. so that if i hover the mouse over the truncated text the name will hover just above. or if you know of a better way anything would be cool.
I would propose doing something like this.
Create a helper with something like this. The truncate method used to take just a length parameter, but this has changed and it now takes a hash of parameters.
def truncate_with_hover(text_to_truncate, length = 30)
"<span title='#{text_to_truncate.gsub("'","\\'")}'>#{truncate(text_to_truncate, :length => length)}</span>" if !text_to_truncate.blank?
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With