0

I'm not sure how informative the title is but here is what I am doing...

I have a vertical menu on the left of my page which has smallish paragraphs set out in a list and I am using javascript's substring method to truncate the number of words and replace them with three dots, call it 'ellipsing' or whatever you may.

However is there any way to keep that view but also make it so that when I click on one of the paragraphs it uses the entire/original string that was there? because so far it only retrieves the truncated string.

Further to add the so called paragraphs are actually text that are pulled out from a database and put in the div tag...using asp here.

6
  • 1
    Sure, there's a way to do that. Keep the original string somewhere and add a click handler that shows the original string. Not sure what kind of help you really expect here. Commented Dec 12, 2013 at 14:35
  • ideas are good thank you :) Commented Dec 12, 2013 at 14:36
  • text-overflow: ellipis Commented Dec 12, 2013 at 14:36
  • 1
    I suggest using the css ellipsing and toggle it using a class when you clic on one of the elements Commented Dec 12, 2013 at 14:36
  • 1
    Would help if you posted some code as an example of what you have already. Commented Dec 12, 2013 at 14:37

2 Answers 2

1

Create a css class like this:

.ellip {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

Apply this class to your menu items (paragraphs as you call them). The parent of those menu-items should have a width.

See this fiddle: http://jsfiddle.net/88mmf/

This will help you understand how to use javascript or jQuery to toggle this class on click.

Hope that helps.

Sign up to request clarification or add additional context in comments.

3 Comments

interesting, when I had tried white-space no wrap before with text-overflow hidden, it didn't work as well because I didn't use overflow:hidden.. thank you, it has done the trick
@user2405469: Glad to help. I have updated the answer to include a fiddle to help you understand better.
thank you, I just implmented the overflow:hidden, done too much with jquery, it is nice to not have included more with the number of things I have in there already.
0

You can keep the whole strings in a global array (window.labels), and reference them either in the truncated version or the full text version:

window.labels = [];
window.labels[0] = 'very long string bla bla bla';
window.labels[1] = ...

1 Comment

now this was the original idea in my head that I just didn't want to go to. I was thinking have the originals stored in some array, get the content of what was clicked and find it in the array and then get that content instead, thinking too much like a programmer, love it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.