jQuery-UI可调整大小,以编程方式调整大小 [英] jQuery-UI resizable, programatically resizing

查看:111
本文介绍了jQuery-UI可调整大小,以编程方式调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用jquery调整div的大小,并具有AlsoResize触发器: 我尝试更改宽度,然后触发调整大小事件,但这不起作用.

I am trying to resize a div with jquery and have the alsoResize trigger: I tried changing the width and then triggering the resize event, but it doesnt work.

小提琴: http://jsfiddle.net/Ns3yn/2/

谢谢!

推荐答案

此问题很有趣.我需要我调整许多"alsoResize"对象的大小以及调整原始对象的大小.

This issue is an interesting one. My need required me to resize many "alsoResize" objects along with resizing the original object.

其中之一是需要的jQuery UI功能:
可调整大小:公开API以编程方式触发调整大小

For one, it is a requested jQuery UI feature:
Resizable: Expose an API for programatically triggering a resize

但是,在实现该功能之前,代替我自己创建此功能,我找到了一个相当不错的快速解决方案.解决方案来自这里:
以编程方式调整可调整大小的元素的大小

But, until that is implemented, in lieu of creating this feature myself, I have found a pretty decent quick solution. The solution comes from here:
Programmatically Resize a resizable element


该解决方案使用一些模拟鼠标拖动的jquery单元测试库.您可以在此处找到必要的库:
jquery.simulate.js
resizable_test_helpers.js


The solution uses some jquery unit testing libraries that simulate a mouse drag. You can find the necessary libraries here:
jquery.simulate.js
resizable_test_helpers.js


因此,请在上面包含这两个文件,然后您可以运行以下代码:


So include those two files above, then you can run code like this:

var handle = ".ui-resizable-se";
TestHelpers.resizable.drag(handle, 50, 50);

这将以编程方式将对象上下左右调整50像素.

This will programatically resize your object by 50 pixels right and down.

这篇关于jQuery-UI可调整大小,以编程方式调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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