halla
2007-Jan-15 03:13 UTC
Scriptacolous InPlaceEditor: Linebreaks are gone after submitting the form
Hi, when using the Scriptacolous Ajax.InPlaceEditor I can use the "loadTextURL"-Parameter to get a Text from a Database, which should be displayed in a Form for Editing. After submitting the Form, the same Text is displayed instead of the Form. My problem is, that I''d need access to the Text, which is displayed AFTER submitting the form. Is there a way to alter this text? Background: I store the text in the Database without any <br />-Tags, just "\n"-linebreaks. When retrieving the text from the DB to display it in the form, this keeps my linebreaks like they should. But after submitting and showing the same text as "normal" HTML, all my linebreaks are gone :-( f.e. in the form, my text looks like this: 1st Row, 2nd Row, 3td Row. After submitting the InPlaceEditor-Form, the same text is displayed like this: 1st Row, 2nd Row, 3td Row Does anybody know how to solve this? Have a nice day, Daniel --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Daniel Haller
2007-Jan-15 11:35 UTC
Scriptacolous InPlaceEditor: Linebreaks are gone after submitting the form
Hi, my name is Daniel, this is my first posting into this list. Please excuse my poor english, I''m from germany, so this is not my mothertongue I''m writing in. When using the Scriptacolous Ajax.InPlaceEditor I can use the "loadTextURL"-Parameter to pull a Text out of a Database, which should be displayed in a Form for Editing. After submitting the Form, the same Text is displayed instead of the Form. My problem is, that I''d need access to the Text, which is displayed AFTER submitting the form. Is there a way to alter this text? Background: I store the text in the Database without any <br />-Tags, just "\n"-linebreaks. When retrieving the text from the DB to display it in the form, this keeps my linebreaks like they should. But after submitting and showing the same text as "normal" HTML, all my linebreaks are gone :-( f.e. in the form, my text looks like this: 1st Row, 2nd Row, 3td Row. After submitting the InPlaceEditor-Form, the same text is displayed like this: 1st Row, 2nd Row, 3td Row Does anybody know how to solve this? Have a nice day, Daniel --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Colin Mollenhour
2007-Jan-19 09:47 UTC
Re: Scriptacolous InPlaceEditor: Linebreaks are gone after submitting the form
Two options come to mind: 1) IPE has a handleLineBreaks option which defaults to true. So, always have the server convert newlines to <br/> before sending the text (both in the original page load and in response to a submit) and remove the loadTextURL option (doesn''t seem like you need it in this case). 2) IPE uses Ajax.Updater unless evalScripts is true. So, pass an insertion function into ajaxOptions that will convert newlines into <br/> before calling Element.update. ajaxOptions: { insertion: function(element,content){ element.update(content.replace(/\\n/gi, "<br/>")); } } This won''t work if you need evalScripts since IPE in all of it''s retardedness uses the same ajaxOptions for both the loadExternalText and the onSubmit... so you can''t have separate "parameters", "onComplete"s, etc.. Luckily Ajax.Updater is used by onSubmit so this is ignored by the loadExternalText Ajax.Request. However, if you are using ajaxOptions for loadExternalText this will be really confusing to other people, "Why is he specifying an insertion for an Ajax.Request?" I''ll say it again, IPE needs to be rewritten. Colin halla wrote:> > Hi, > > when using the Scriptacolous Ajax.InPlaceEditor I can use the > "loadTextURL"-Parameter to get a Text from a Database, which should be > displayed in a Form for Editing. After submitting the Form, the same > Text is displayed instead of the Form. > > My problem is, that I''d need access to the Text, which is displayed > AFTER submitting the form. Is there a way to alter this text? > > Background: > I store the text in the Database without any <br />-Tags, just > "\n"-linebreaks. When retrieving the text from the DB to display it in > the form, this keeps my linebreaks like they should. But after > submitting and showing the same text as "normal" HTML, all my > linebreaks are gone :-( > > f.e. in the form, my text looks like this: > 1st Row, > 2nd Row, > 3td Row. > After submitting the InPlaceEditor-Form, the same text is displayed > like this: > 1st Row, 2nd Row, 3td Row > > Does anybody know how to solve this? > Have a nice day, > Daniel > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---