Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Mobile growing text area with AJAX data

I am loading text to an input box via the $("textarea").val(ajaxData); however it will not autogrow, and my data is not fully displayed. Is there any method or anything that I can call to force an update?

like image 892
Astronaut Avatar asked May 22 '12 09:05

Astronaut


1 Answers

There's indeed an internal function that is responsible for resizing, called resizeCheck(). However, that function is a private implementation detail and is not exposed by the widget as a public method.

You can work around this, though: since resizeCheck() is called by the widget's keyup event handler, you can trigger that event yourself after setting the new value:

$("textarea").val(ajaxData).keyup();

This will resize the widget in the exact same way as if you had typed the new text "by hand".

like image 66
Frédéric Hamidi Avatar answered Nov 12 '22 02:11

Frédéric Hamidi