yuanqing/autosize-input

trigger event

Opened this issue · 2 comments

I have functionality that updated the input value in other way that typing into the input field (e.g. click a button and update the input to 'test value').

$('#search').val('test-value')

I need to trigger an event to update the width of the input field. I tried using jquery trigger with 'keydown', 'change' and 'input' events, but nothing happened:

$('#search').trigger('input')

Please make a solution for it!

I found a work-around for this. The autosizeInput call returns a function that can be invoked to update the size of the input. You can run that function with an interval timer to pull for changes:

var autosize = autosizeInput(elem)
setInterval(function () { autosize() }, 100)