views:

27

answers:

1

Im doing a textarea with jeditable. The content is saved and loaded from a database. But im having some problems in the way IE and FF handles linebreaks differently.

After some debugging i've found a mysterious behavior in FF. For example if i input in textarea:

1
2

It will return

1<br>2

Which is fine. But if i write:

1
2
3

It returns

1<br>2<br>
3

How come? And how am i supposed to do regexp on this abnormal behaviour.

Atm. im doing this regexp:

  data      : function(value, settings) {
      /* Convert <br> to newline. */
      retval = value(/<br[\s\/]?>/gi, '\n');
      return retval;
 },

Which works fine in IE, but in FF (because of this behaviour) it returns more linebreaks than supposed to.

Can you help ?

Thanks in advance

A: 

If you're expecting the text to have no newlines in it, why not just strip them out before you convert the <br>s to newlines?

value = value.replace(/(\r\n|[\r\n])/g,'');
retval = value.replace(/<br[\s\/]?>/gi, '\n');
robertc
It still puts an extra \n in firefox-.-
s0mmer
I guess the regexp doesnt work. When using var retval = value.replace(/\\n/gi,'TEST'); it doesnt outputs any "TEST"
s0mmer
@s0mmer so try a different regex, I took a new one from here: http://lawrence.ecorp.net/inet/samples/regexp-format.php
robertc