0

In a form I have

{{> afFieldInput id='idMeContacterInputMessage' class="formInput"    name='message' type='textarea' rows=3
                        style="position:absolute; top:22px; left:0px; width:380px;"}}

and

Template.meContacter.rendered =function(){
    $('#idMeContacterInputMessage').autosize()
.....

autosize() is from 'copleykj:jquery-autosize'

This is Ok. The textarea element is automatically resized for entering characters.

I would now like to capture the event corresponding to the resizing of my textarea

I tried this without success

Template.meContacter.rendered =function(){
    $('#idMeContacterInputMessage').autosize()
    var ta = document.getElementById('idMeContacterInputMessage');
    ta.addEventListener('autosize:resized', function(){
        console.log('textarea height updated');
    });

Please, is there anyone can help me? Thank you

yvan Coyaud
  • 167
  • 1
  • 1
  • 10

1 Answers1

0

I've not tested this, but going by the example stated, it seems to be similar to what you're asking.

  1. Approach 1
  2. Approach 2

If you take a look at approach 1, you can bind to input event and constantly check the number of rows of the textarea. If it is > 3, then set a reactive variable (a Session, maybe) to make it do whatever you want to do next.

Community
  • 1
  • 1
blueren
  • 2,730
  • 4
  • 30
  • 47