PDA

View Full Version : Problem with Ext Editor, new line and IE 7



emwe80
23 Feb 2009, 2:44 AM
Hi,
I'm using the ext2 Editor and want it to edit a html Element on my page. I need the contained <BR>-Tags to be converted into regular new line characters (so that users see them as normal line breaks inside the editor). After editing, the newline characters are converted back to <BR>-Tags. This works fine in Firefox but in IE6 and IE7 it won't. I have written this small function to do the replacement prior to opening the editor:


function html2text(html){
var result = html.replace(/<BR>/g, "\n");
return result;
}

But when the Editor opens on IE the line breaks are gone (replaced by simple white spaces). I found several posts in the forum that inspired me to try something like:


var result = html.replace(/<BR>/g, "\\n");

but that didn't work any better (the \\n were shown as \n inside the editor).

Thanks in advance,

Emwe

24 Feb 2009, 7:56 AM
Hi,
I'm using the ext2 Editor and want it to edit a html Element on my page. I need the contained <BR>-Tags to be converted into regular new line characters (so that users see them as normal line breaks inside the editor). After editing, the newline characters are converted back to <BR>-Tags. This works fine in Firefox but in IE6 and IE7 it won't. I have written this small function to do the replacement prior to opening the editor:


function html2text(html){
var result = html.replace(/<BR>/g, "\n");
return result;
}

But when the Editor opens on IE the line breaks are gone (replaced by simple white spaces). I found several posts in the forum that inspired me to try something like:


var result = html.replace(/<BR>/g, "\\n");

but that didn't work any better (the \\n were shown as \n inside the editor).

Thanks in advance,

Emwe
Wha'ts the ext2 editor? The html editor?

emwe80
26 Feb 2009, 6:06 AM
It's the Class Ext.Editor in Package Ext.

emwe80
1 Mar 2009, 11:20 PM
The problem has been solved.
My mistake was to store the converted text inside the inner html before editing. This works fine on Firefox but not on IE. The solution was quite simple: the Ext.Editor's startedit method takes the input as an optional second argument. Directly using the result of my html2text-function as second argument for startedit (instead of setting the target element's inner html and then editing it with the editor) solved the issue.