materialize: Dynamically created textarea is not resizing
Description
When textarea control is created dynamically, auto-resize is not fired.
$('.materialize-textarea').trigger('autoresize');
won’t help, as textarea does not have autoresize
event bound to it. The only time it is set - is $(document).ready
.
Maybe you can add some initialization for dynamically created controls, similar to what we can use for select
elements - $('select').material_select();
?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 27 (11 by maintainers)
Seems we have to add a check for
data('original-height') === undefined
or similar.Workaround (set
data-original-height=0
) http://codepen.io/anon/pen/QvpdvOM.textareaAutoResize(document.querySelector(‘.materialize-textarea’))
set
data-original-height=0
worked for me with the version 0.98.2
Fixed in 4a3c15c
Exactly 😉 https://github.com/Dogfalo/materialize/issues/4613#issuecomment-297950328
https://github.com/Dogfalo/materialize/blob/master/js/forms.js#L179-L181
http://api.jquery.com/on/
For me it seems to work as it should: http://codepen.io/anon/pen/xdgjzr