填充文本后切换调整 materializecss textareas 的大小
Toggle resizing on materializecss textareas after populating the text
说我有这个:
<div class="row">
<form class="col s12">
<div class="row">
<div class="input-field col s12">
<textarea id="textarea1" class="materialize-textarea"></textarea>
<label for="textarea1">Textarea</label>
</div>
</div>
</form>
</div>
并说我的代码的某些部分 运行 这个:
$('#textarea1').text(someverylongstring)
这个问题是我的文本区域将保持 "small",直到我单击它并向下箭头找到我添加到其中的文本。当找到底部时,文本区域会自动扩展到更大的文本区域以容纳内容。我的问题是,将文本添加到文本区域后,是否有办法强制切换元素的大小调整方面?
你试过他们docs的高级笔记了吗?
When dynamically changing the value of a textarea with methods like jQuery's .val(), you must trigger an autoresize on it afterwords because .val() does not automatically trigger the events we've binded to the textarea.
所以在添加很长的文本后,您可以调用它:
$('#textarea1').trigger('autoresize');
我在 VueJS 中使用这个
M.textareaAutoResize($('#textarea1'));
如果不起作用,请尝试在启动 autoResize
之前设置超时。
说我有这个:
<div class="row">
<form class="col s12">
<div class="row">
<div class="input-field col s12">
<textarea id="textarea1" class="materialize-textarea"></textarea>
<label for="textarea1">Textarea</label>
</div>
</div>
</form>
</div>
并说我的代码的某些部分 运行 这个:
$('#textarea1').text(someverylongstring)
这个问题是我的文本区域将保持 "small",直到我单击它并向下箭头找到我添加到其中的文本。当找到底部时,文本区域会自动扩展到更大的文本区域以容纳内容。我的问题是,将文本添加到文本区域后,是否有办法强制切换元素的大小调整方面?
你试过他们docs的高级笔记了吗?
When dynamically changing the value of a textarea with methods like jQuery's .val(), you must trigger an autoresize on it afterwords because .val() does not automatically trigger the events we've binded to the textarea.
所以在添加很长的文本后,您可以调用它:
$('#textarea1').trigger('autoresize');
我在 VueJS 中使用这个
M.textareaAutoResize($('#textarea1'));
如果不起作用,请尝试在启动 autoResize
之前设置超时。