2

I have the following snippet of code for auto expanding the textarea in sencha touch. I need to cap it out at a set number of rows.

Any ideas?

http://www.senchafiddle.com/#Q9gjN

cclerv
  • 2,921
  • 8
  • 35
  • 43
Quotient
  • 3,925
  • 6
  • 31
  • 35

1 Answers1

0

Wouldn't this be great if it were a nice, easy to use property.

At first I thought it would be the maxRows property but this is just the number of rows to display before the vertical scrollbar appears.

It may be that the only way would be a complicated solution such as this: http://www.codeproject.com/Articles/56392/How-to-Limit-the-Number-of-Lines-and-Characters-in

or

Limiting number of lines in textarea

EDIT: I needed to cap the number of rows in an address to 5 lines.

One approach could be to listen to the keyup event on the textareafield, check for the 'Enter' key and then revert back to previous input.

The approach I have taken is just to add validation to the model, which works great.

{ type: 'format', field: 'Address', message: 'Address cannot be more than 5 lines.', matcher: /^([^\r\n]{0,50}(\r?\n|$)){5}$/ }

The regex restricts saving a record to the store that has more than 5 lines, of more than 50 chars.

Community
  • 1
  • 1
Adam Marshall
  • 3,010
  • 9
  • 42
  • 80