1. #1
    Ext User dreamin's Avatar
    Join Date
    Jun 2010
    Posts
    6
    Vote Rating
    0
    dreamin is on a distinguished road

      0  

    Default How catch (and replace) carriage returns in a Ext.form.TextArea value

    How catch (and replace) carriage returns in a Ext.form.TextArea value


    Hi all,
    I have a normal Ext.form.TextArea who saves its data into a normal mysql database.
    When I load the text into the TextArea all is fine: the carriage returns are hidden, but they exists because the text is splitted into lines.
    My problem is to show that text into a web page, but mantaining the text format, so the carriage returns must be ideally replaced by a <br/>.

    [start of the example]

    TEXT IN MY TEXTAREA:
    ---------------------------
    Hallo,
    this is my foo text.

    Do you like it?

    SAME TEXT, SHOWN IN A WEBPAGE
    ----------------------------------------
    Hallo, this is my foo text. Do you like it?

    [end of the example]

    Someone can suggest me the right way to operate? Thanks!

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    When exactly do you want to replace carriage returns with <br/>s?

    ps. You can use the Ext.util.Format.nl2br function to do this.

  3. #3
    Ext User dreamin's Avatar
    Join Date
    Jun 2010
    Posts
    6
    Vote Rating
    0
    dreamin is on a distinguished road

      0  

    Default


    Hi Condor,
    thanks in advance for your fast suggestion!

    I want to replace it at a PHP level, so maybe I must do this:

    1. add a new field to the db table, named "html_description" (current one is named simply "description")
    2. add a "onblur" listener to the textarea which fills a hidden input of the form, named "html_description"
    3. save the normal text in the "description" field of the db table, and the html text in the "html_description" (using your suggestion), so the first text will be used always in the textarea and the 2nd in the web pages

  4. #4
    Sencha User darthwes's Avatar
    Join Date
    Mar 2010
    Posts
    633
    Vote Rating
    -13
    darthwes can only hope to improve

      0  

    Default


    Code:
    function ta_renderer(v) {
      return Ext.util.Format.nl2br(v);
    }
    ...
    {
      dataIndex: whatevID,
      type: 'string',
      editor: new Ext.form.TextArea({
        allowBlank: false,
        ...
      }),
      renderer: ta_renderer,
      ...
    }
    ...
    Just set up a renderer?
    Wes

  5. #5
    Ext User dreamin's Avatar
    Join Date
    Jun 2010
    Posts
    6
    Vote Rating
    0
    dreamin is on a distinguished road

      0  

    Default


    Thank you darthwes.
    I chose to add a "keypress" listener to the textarea, who fills a hidden field of the form with the text formatted by Ext.util.Format.nl2br function.

    Many thanks,
    Michele
    Web per vocazione

Similar Threads

  1. Replace textarea with Ext.form.TextArea
    By UnarmedHunter in forum Ext 3.x: Help & Discussion
    Replies: 4
    Last Post: 26 Oct 2009, 1:00 AM
  2. catch enter in Ext.form.TextArea and active defaultbutton in form
    By mdissel in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 6 Sep 2008, 6:17 AM
  3. disable catch or carriage return for formPanel
    By mxu in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 7 Jan 2008, 1:26 PM
  4. carriage returns in textarea not encoded
    By sj137 in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 15 May 2007, 3:12 AM

Thread Participants: 2

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar