textarea_grow jquery plugin
[MojoFacets.git] / public / js / jquery.textarea_grow.js
1 jQuery.fn.textarea_grow = function(){
2         return this.each(function(){
3                 var rows = this.rows;
4                 console.debug( 'textarea_grow', rows, this );
5                 var grow = function(ta) {
6                 var lines = ta.value.split('\n').length;
7                         if ( lines > rows ) {
8                                 ta.rows = lines;
9                                 //console.debug('keyup', lines, rows, ta );
10                         }
11                 };
12                 grow(this);
13                 this.onkeyup = function() { grow(this) };
14         });
15 };
16