jQuery Mobile使用AJAX数据扩展文本区域 [英] jQuery Mobile growing text area with AJAX data

查看:57
本文介绍了jQuery Mobile使用AJAX数据扩展文本区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过$("textarea").val(ajaxData);将文本加载到输入框,但是它不会自动增长,并且我的数据没有完全显示.有什么方法或我可以调用的方法来强制更新吗?

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?

推荐答案

确实存在一个负责调整大小的内部函数,称为resizeCheck().但是,该函数是私有实现的细节,并且未由窗口小部件公开为公共方法.

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.

但是,您可以解决此问题:由于resizeCheck()由窗口小部件的keyup事件处理程序调用,因此您可以在设置新值后自行触发该事件:

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".

这篇关于jQuery Mobile使用AJAX数据扩展文本区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆