kswedberg / jquery-expander

Expand and Collapse HTML content
https://kswedberg.github.io/jquery-expander/
Other
459 stars 167 forks source link

Fixing the multiple line issue #2

Closed digiguru closed 13 years ago

digiguru commented 13 years ago

Hi kswedberg.

I have made a slight modification to the code to change the HTML after expanding truncated text to the originalHTML that was in the document. This means any special formatting, like line breaks and CSS styles are honoured.

You can try it by using the plugin on a div that has multiple P elements inside.

To perform this, I have had to add a data property to the original matched node that stores the HTML before it is truncated, and after it is truncated. I have also needed to create an event called "ReBindClicks". This is an event that occurs after the expander has initially loaded, and upon every subsequent Collapse event to rebind the jquery events to the HTML.

Please have a look at the code, it's based on your latest version and works exactly as before.

If you have any further enhancements, I'm happy to continue working on it.

You can play with a demo here: http://jsfiddle.net/digiguru/PVsXd/4/

Many Thanks

kswedberg commented 13 years ago

Thanks so much for the pull request, and sorry it has taken me a while to get back to you. I just took a look at the diff, and it's really hard to make out what you actually changed because of all of the whitespace changes. It basically looks like the whole plugin has changed, even though I know that can't be the case. I'll have to spend more time going through it, but I'm swamped with other work at the moment. If you could maybe point me to the salient changes, I'd greatly appreciate it.

Thanks again.

digiguru commented 13 years ago

I'll try to make another request with the whitespace matching the original.