Side navigation
#8815 closed bug (invalid)
Opened April 08, 2011 05:16AM UTC
Closed July 12, 2011 07:45PM UTC
Last modified March 14, 2012 04:59PM UTC
jQuery's html() function removes tabs in IE 8 when it shouldn't
Reported by: | tim@timothyjcoulter.com | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | manipulation | Version: | 1.5.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
See jsFiddle here:
Notice that in setting the HTML of somediv using the html() function, there are four tabs. In the latest Chrome, Safari, and Firefox, these tabs remain: i.e, there is a tab character at the beginning of each line. However, in Internet Explorer 8, all tab characters following the first are removed.
Note that I'm setting the HTML from the server that has characters saved in the data. This is for a contenteditable div used for rich text editing within my application.
Attachments (0)
Change History (4)
Changed April 08, 2011 05:19AM UTC by comment:1
Changed April 15, 2011 04:56AM UTC by comment:2
component: | unfiled → manipulation |
---|---|
priority: | undecided → low |
status: | new → open |
Changed July 12, 2011 07:45PM UTC by comment:3
resolution: | → invalid |
---|---|
status: | open → closed |
I think the issue is that you're conflating HTML (where whitespace tends to be insignificant) and text/pre - where you should probably be using .text("your text") instead. You should just convert the <br>s to \\n and you'll be good to go!
Changed July 31, 2011 09:34PM UTC by comment:4
Why would this work correctly (correctly being that the tab is preserved) in every other browser but IE?
I can't use text() because I'm pulling HTML across the wire so it can be placed into a contenteditable div (think, text editor). To work around this, I need to add a <tab> html tag before the html() command, then replace all <tab> tags with the actual tab character. In javascript, the data flows like this:
Get data from server, with tab character -> convert to <tab> -> use html() -> convert <tab> back to tab character.
This seems like the perfect place for jQuery.
That last part should say: *tab* characters saved in the data.