AnanthaKN / jquery-in-place-editor

Automatically exported from code.google.com/p/jquery-in-place-editor
Other
0 stars 0 forks source link

New line in text area #95

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
1. Click on the text area in the demo page (example #2 in 
http://jquery-in-place-editor.googlecode.com/svn/trunk/demo/index.html)

2. Add some text and a new line. Click outside

3. The new line disappears

Original issue reported on code.google.com by ishim...@gmail.com on 10 Jun 2011 at 5:12

GoogleCodeExporter commented 8 years ago
Line 437: var savingMessage = enteredText;
Change to: var savingMessage = 
enteredText.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ '<br />' +'$2');

and also line 488: var new_text = html || that.settings.default_text;
Change to: var new_text = html.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ 
'<br />' +'$2'); || that.settings.default_text;

Probably not going to win any awards for beautiful code, but it works...

Original comment by jy...@hotmail.com on 31 Jan 2012 at 5:28

GoogleCodeExporter commented 8 years ago
Actually this was a little more complicated than I thought.  To get it working 
in IE needed a few more fixes:

saveOriginalValue: function() {
    if (this.settings.use_html) {
        var html = this.dom.html().replace(/\n/ig,'')
        this.originalValue = html.replace(/<BR>/ig,'\n');
    } else {
        this.originalValue = trim(this.dom.text());
    }
},

AND

setClosedEditorContent: function(aValue) {
    if (this.settings.use_html)
        this.dom.html(aValue.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ '<BR>' +'$2'));
    else
        this.dom.text(aValue);
},

Tested in FF, IE, Safari, Chrome, Opera
Only works completely if use_html setting is true

Original comment by jy...@hotmail.com on 1 Feb 2012 at 1:18

GoogleCodeExporter commented 8 years ago
Hi there

I'm experiencing the same problem, and I've tried implementing the fixes above 
but it just makes jQuery in Place Editor stop working altogether. 

I did notice that the new line 488 has an incorrect semi-colon just before the 
||, and that the new 'saveOriginalValue' function is missing a semi-colon on 
the third line, but after correcting those it doesn't work. I can't see 
anything obvious wrong with it either...

I had thought that this issue could be address using the 'callback' function, 
but on further thought I think this plugin should handle it in it's code. 

If anyone has a working solution please let me know.
Cheers
Matt

Original comment by ultraweb...@gmail.com on 7 May 2012 at 11:35

GoogleCodeExporter commented 8 years ago
Would love a status check of this issue..

Original comment by miser...@gmail.com on 6 Nov 2013 at 10:04

GoogleCodeExporter commented 8 years ago
FYI I concluded it was far simpler in the end just to use an actual <textarea> 
element, and style it look how you want (eg. remove borders, so it doesn't look 
like a form field), and then add styling on hover and 'focus' to make it look 
editable. I am using the same approach for all my form fields now in fact.

Original comment by ultraweb...@gmail.com on 6 Nov 2013 at 10:19